@trim21/personal-pi-extensions 0.0.338 → 0.0.340

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.338",
3
+ "version": "0.0.340",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
package/src/aft/tools.ts CHANGED
@@ -156,6 +156,7 @@ export function registerOutlineTool(pi: ExtensionAPI, ctx: AftToolContext): void
156
156
  content: [{ type: "text", text }],
157
157
  details: {
158
158
  truncated,
159
+ params,
159
160
  },
160
161
  };
161
162
  },
@@ -220,6 +221,7 @@ export function registerZoomTool(pi: ExtensionAPI, ctx: AftToolContext): void {
220
221
  content: [{ type: "text", text }],
221
222
  details: {
222
223
  truncated,
224
+ params,
223
225
  pendant: {
224
226
  title: "aft_zoom",
225
227
  subtitle,
@@ -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"],