token-goat 2.8.4 → 2.9.1
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 -8
- package/dist/{token-goat-chunk-NZFTWBGV.mjs → token-goat-chunk-4KD2N46D.mjs} +28 -27
- package/dist/{token-goat-chunk-CZALRRGN.mjs → token-goat-chunk-4ZDRTNGV.mjs} +9942 -95
- package/dist/{token-goat-chunk-L6YP6FKQ.mjs → token-goat-chunk-AUM22UQ2.mjs} +5 -5
- package/dist/{token-goat-chunk-LZOAPGWR.mjs → token-goat-chunk-CD6U5OD6.mjs} +28 -4
- package/dist/{token-goat-chunk-4OTIB7SB.mjs → token-goat-chunk-FDXINYK4.mjs} +2120 -3658
- package/dist/token-goat-chunk-LHMC5ENL.mjs +79 -0
- package/dist/{token-goat-chunk-IZRXU64B.mjs → token-goat-chunk-MR7MNSDR.mjs} +155 -517
- package/dist/{token-goat-chunk-ZQ3PUOP3.mjs → token-goat-chunk-RRNRPCLX.mjs} +167 -116
- package/dist/{token-goat-chunk-U4UI5F3S.mjs → token-goat-chunk-SQSB5P5P.mjs} +842 -368
- package/dist/{token-goat-chunk-RE7S7H26.mjs → token-goat-chunk-SXSWQMNP.mjs} +512 -206
- package/dist/{token-goat-chunk-HNODKNWO.mjs → token-goat-chunk-V5T3YNYR.mjs} +5 -5
- package/dist/token-goat-hook.mjs +5 -5
- package/dist/token-goat.core.mjs +5 -5
- package/package.json +1 -1
- package/dist/token-goat-chunk-E76UNTVK.mjs +0 -7133
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
detectHarness
|
|
5
|
+
} from "./token-goat-chunk-4ZDRTNGV.mjs";
|
|
6
|
+
|
|
7
|
+
// src/delivery_cap.ts
|
|
8
|
+
var CLAUDE_CODE_BASH_OUTPUT_CAP_BYTES = 2e4;
|
|
9
|
+
function bashOutputCapBytes(harness = detectHarness()) {
|
|
10
|
+
return harness === "claudecode" ? CLAUDE_CODE_BASH_OUTPUT_CAP_BYTES : null;
|
|
11
|
+
}
|
|
12
|
+
function deliveredOutputBytes(originalBytes, harness) {
|
|
13
|
+
const cap = bashOutputCapBytes(harness);
|
|
14
|
+
if (cap === null) return Math.max(0, originalBytes);
|
|
15
|
+
return Math.max(0, Math.min(originalBytes, cap));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/shell.ts
|
|
19
|
+
import * as fs from "node:fs";
|
|
20
|
+
import * as path from "node:path";
|
|
21
|
+
var WSL_LAUNCHER_SEGMENTS = /* @__PURE__ */ new Set(["system32", "syswow64", "windowsapps"]);
|
|
22
|
+
function isExecutable(p) {
|
|
23
|
+
try {
|
|
24
|
+
return fs.statSync(p).isFile();
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function isWslLauncherDir(dir) {
|
|
30
|
+
return dir.toLowerCase().split(/[\\/]+/).some((seg) => WSL_LAUNCHER_SEGMENTS.has(seg));
|
|
31
|
+
}
|
|
32
|
+
function locateBashOnPath(pathValue, isExe = isExecutable) {
|
|
33
|
+
for (const dir of (pathValue ?? "").split(path.delimiter)) {
|
|
34
|
+
if (!dir || isWslLauncherDir(dir)) continue;
|
|
35
|
+
const cand = path.join(dir, "bash.exe");
|
|
36
|
+
if (isExe(cand)) return cand;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function knownGitBashPaths() {
|
|
41
|
+
const localPrograms = process.env["LOCALAPPDATA"] ? path.join(process.env["LOCALAPPDATA"], "Programs") : void 0;
|
|
42
|
+
const bases = [
|
|
43
|
+
process.env["ProgramFiles"],
|
|
44
|
+
process.env["ProgramFiles(x86)"],
|
|
45
|
+
process.env["ProgramW6432"],
|
|
46
|
+
localPrograms
|
|
47
|
+
];
|
|
48
|
+
const out = [];
|
|
49
|
+
for (const base of bases) {
|
|
50
|
+
if (!base) continue;
|
|
51
|
+
out.push(path.join(base, "Git", "bin", "bash.exe"));
|
|
52
|
+
out.push(path.join(base, "Git", "usr", "bin", "bash.exe"));
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function resolveWindowsBash() {
|
|
57
|
+
if (process.platform !== "win32") return null;
|
|
58
|
+
const override = process.env["TOKEN_GOAT_BASH"];
|
|
59
|
+
if (override && isExecutable(override)) return override;
|
|
60
|
+
const onPath = locateBashOnPath(process.env["PATH"]);
|
|
61
|
+
if (onPath) return onPath;
|
|
62
|
+
for (const cand of knownGitBashPaths()) {
|
|
63
|
+
if (isExecutable(cand)) return cand;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
function wrappedShell() {
|
|
68
|
+
if (process.platform !== "win32") return true;
|
|
69
|
+
return resolveWindowsBash() ?? true;
|
|
70
|
+
}
|
|
71
|
+
function canRunWrappedShell() {
|
|
72
|
+
return process.platform !== "win32" || resolveWindowsBash() !== null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
deliveredOutputBytes,
|
|
77
|
+
wrappedShell,
|
|
78
|
+
canRunWrappedShell
|
|
79
|
+
};
|