blun-king-cli 9.1.428 → 9.1.429
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/bin/windows-bash-dialect-policy.cjs +25 -0
- package/blun.mjs +12 -2
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const EXPLICIT_CMD_HANDOFF = /(?:^|[;&|]\s*)cmd(?:\.exe)?\s+(?:(?:\/[dqs])\s+)*\/c(?=\s|$)/iu;
|
|
4
|
+
const CMD_MARKERS = [
|
|
5
|
+
['cd /d', /(?:^|[;&|]\s*)cd\s+\/d(?=\s|$)/iu],
|
|
6
|
+
['dir /s /b', /(?:^|[;&|]\s*)dir\s+\/s\s+\/b(?=\s|$)/iu],
|
|
7
|
+
['find /c /v', /(?:^|[;&|]\s*)find\s+\/c\s+\/v(?=\s|$)/iu],
|
|
8
|
+
['2>nul', /(?:^|[\s;|&])(?:[012]?>|&>)\s*nul(?=$|[\s;|&])/iu],
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
function windowsBashDialectRefusal({ command, isWindowsBash = false } = {}) {
|
|
12
|
+
if (!isWindowsBash) return undefined;
|
|
13
|
+
const source = String(command || '');
|
|
14
|
+
if (EXPLICIT_CMD_HANDOFF.test(source)) return undefined;
|
|
15
|
+
|
|
16
|
+
const found = CMD_MARKERS.filter(([, pattern]) => pattern.test(source)).map(([label]) => label);
|
|
17
|
+
if (found.length === 0) return undefined;
|
|
18
|
+
|
|
19
|
+
return `Refused Windows cmd.exe syntax in the Bash tool before execution (found: ${found.join(', ')}). `
|
|
20
|
+
+ 'This tool runs POSIX Bash on Windows, including inside VS Code. Pass the directory with cwd, '
|
|
21
|
+
+ 'use Bash paths and commands such as find or rg, and redirect to /dev/null. '
|
|
22
|
+
+ 'If cmd semantics are intentional, invoke cmd.exe /d /s /c explicitly.';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = { windowsBashDialectRefusal };
|
package/blun.mjs
CHANGED
|
@@ -263222,7 +263222,7 @@ function windowsPathToPosixPath(path) {
|
|
|
263222
263222
|
function rewriteWindowsNullRedirect(command) {
|
|
263223
263223
|
return command.replace(WINDOWS_NUL_REDIRECT, "$1/dev/null");
|
|
263224
263224
|
}
|
|
263225
|
-
var MS_PER_SECOND, DEFAULT_TIMEOUT_S, MAX_TIMEOUT_S, DEFAULT_BACKGROUND_TIMEOUT_S, MAX_BACKGROUND_TIMEOUT_S, USER_INTERRUPT_REASON, BashInputSchema, SHELL_TIMEOUT_VARS, BashTool, WINDOWS_NUL_REDIRECT, broadRecursiveSearchRefusal;
|
|
263225
|
+
var MS_PER_SECOND, DEFAULT_TIMEOUT_S, MAX_TIMEOUT_S, DEFAULT_BACKGROUND_TIMEOUT_S, MAX_BACKGROUND_TIMEOUT_S, USER_INTERRUPT_REASON, BashInputSchema, SHELL_TIMEOUT_VARS, BashTool, WINDOWS_NUL_REDIRECT, broadRecursiveSearchRefusal, windowsBashDialectRefusal;
|
|
263226
263226
|
var init_bash = __esmMin((() => {
|
|
263227
263227
|
init_zod$1();
|
|
263228
263228
|
init_background();
|
|
@@ -263232,6 +263232,7 @@ var init_bash = __esmMin((() => {
|
|
|
263232
263232
|
init_result_builder();
|
|
263233
263233
|
init_bash$1();
|
|
263234
263234
|
({ broadRecursiveSearchRefusal } = createRequire(import.meta.url)("./bin/bash-search-scope-policy.cjs"));
|
|
263235
|
+
({ windowsBashDialectRefusal } = createRequire(import.meta.url)("./bin/windows-bash-dialect-policy.cjs"));
|
|
263235
263236
|
MS_PER_SECOND = 1e3;
|
|
263236
263237
|
DEFAULT_TIMEOUT_S = 60;
|
|
263237
263238
|
MAX_TIMEOUT_S = 300;
|
|
@@ -263284,7 +263285,8 @@ var init_bash = __esmMin((() => {
|
|
|
263284
263285
|
this.backgroundManager = backgroundManager;
|
|
263285
263286
|
this.isWindowsBash = this.kaos.osEnv.osKind === "Windows";
|
|
263286
263287
|
this.allowBackground = options?.allowBackground ?? true;
|
|
263287
|
-
const
|
|
263288
|
+
const windowsDialectNote = this.isWindowsBash ? "\n\nOn Windows this tool still runs POSIX Bash, including inside VS Code. Do not use cmd.exe syntax such as `cd /d`, `dir /s /b`, `find /c /v`, or `2>nul`; pass the directory with `cwd`, use Bash paths and commands, and redirect to `/dev/null`." : "";
|
|
263289
|
+
const rendered = `${renderBashDescription(this.kaos.osEnv.shellName)}${windowsDialectNote}`;
|
|
263288
263290
|
this.description = this.allowBackground ? rendered : withoutBackgroundDescription(rendered);
|
|
263289
263291
|
}
|
|
263290
263292
|
resolveExecution(args) {
|
|
@@ -263401,6 +263403,14 @@ var init_bash = __esmMin((() => {
|
|
|
263401
263403
|
isError: true,
|
|
263402
263404
|
output: "Command cannot be empty."
|
|
263403
263405
|
};
|
|
263406
|
+
const dialectRefusal = windowsBashDialectRefusal({
|
|
263407
|
+
command: args.command,
|
|
263408
|
+
isWindowsBash: this.isWindowsBash
|
|
263409
|
+
});
|
|
263410
|
+
if (dialectRefusal !== void 0) return {
|
|
263411
|
+
isError: true,
|
|
263412
|
+
output: dialectRefusal
|
|
263413
|
+
};
|
|
263404
263414
|
const searchRefusal = broadRecursiveSearchRefusal({
|
|
263405
263415
|
command: args.command,
|
|
263406
263416
|
cwd: args.cwd ?? this.cwd,
|