@trim21/personal-pi-extensions 0.0.337 → 0.0.339

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.0.337",
3
+ "version": "0.0.339",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -42,7 +42,7 @@
42
42
  "@vitest/coverage-v8": "^4.1.10",
43
43
  "eslint": "^10.8.1",
44
44
  "eslint-config-prettier": "10.1.8",
45
- "eslint-plugin-erasable-syntax-only": "0.6.0",
45
+ "eslint-plugin-erasable-syntax-only": "0.7.1",
46
46
  "eslint-plugin-import-x": "^4.17.1",
47
47
  "eslint-plugin-promise": "7.3.0",
48
48
  "eslint-plugin-simple-import-sort": "14.0.0",
@@ -9,12 +9,35 @@ export interface SpawnOptions {
9
9
  env?: NodeJS.ProcessEnv;
10
10
  }
11
11
 
12
+ /** Windows 上 .cmd/.bat 不能直接 CreateProcess,必须经 cmd.exe /c 执行 */
13
+ const CMD_SCRIPT_RE = /\.(cmd|bat)$/i;
14
+
15
+ const quoteWinArg = (value: string): string =>
16
+ /\s|"/.test(value) ? `"${value.replaceAll('"', '""')}"` : value;
17
+
18
+ function windowsScriptCmd(cmd: string, args: string[]): { command: string; args: string[] } {
19
+ if (process.platform !== "win32" || !CMD_SCRIPT_RE.test(cmd)) {
20
+ return { command: cmd, args };
21
+ }
22
+ return {
23
+ // /s 由 cmd 自行处理外层引号;COMSPEC 缺省时用 PATH 里的 cmd.exe
24
+ command: process.env.COMSPEC ?? "cmd.exe",
25
+ args: [
26
+ "/d",
27
+ "/s",
28
+ "/c",
29
+ `${quoteWinArg(cmd)} ${args.map((arg) => quoteWinArg(arg)).join(" ")}`,
30
+ ],
31
+ };
32
+ }
33
+
12
34
  export function spawnProcess(
13
35
  cmd: string,
14
36
  args: string[],
15
37
  options: SpawnOptions = {},
16
38
  ): ChildProcessWithoutNullStreams {
17
- return nodeSpawn(cmd, args, {
39
+ const { command, args: spawnArgs } = windowsScriptCmd(cmd, args);
40
+ return nodeSpawn(command, spawnArgs, {
18
41
  cwd: options.cwd,
19
42
  env: options.env ? { ...process.env, ...options.env } : process.env,
20
43
  stdio: ["pipe", "pipe", "pipe"],