@gogomi/pi-windows-shell 0.1.1 → 0.1.3

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/index.ts CHANGED
@@ -7,9 +7,7 @@
7
7
 
8
8
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
9
9
  import { Type } from "@sinclair/typebox";
10
- import { readFileSync } from "node:fs";
11
- import { dirname, resolve } from "node:path";
12
- import { fileURLToPath } from "node:url";
10
+
13
11
  import {
14
12
  findPowerShell,
15
13
  executePowerShell,
@@ -36,15 +34,119 @@ import {
36
34
  } from "./paths.js";
37
35
  import type { ManagedProcess } from "./types.js";
38
36
 
39
- // Load the Windows shell policy at extension init time
40
- const __dirname = dirname(fileURLToPath(import.meta.url));
41
- const policyPath = resolve(__dirname, "prompts", "windows-shell-policy.md");
42
- let windowsShellPolicy = "";
43
- try {
44
- windowsShellPolicy = readFileSync(policyPath, "utf-8");
45
- } catch {
46
- // Policy file not found — extension still works, just without the policy injection
47
- }
37
+ const windowsShellPolicy = `# Windows Shell Policy
38
+
39
+ The environment runs on Windows.
40
+
41
+ These rules are always active when choosing how to run commands.
42
+
43
+ ## Shell/tool selection
44
+
45
+ Use Bash only for Git-oriented and Unix-like repository inspection workflows:
46
+
47
+ - \`git status\`
48
+ - \`git diff\`
49
+ - \`git log\`
50
+ - \`git grep\`
51
+ - patch inspection
52
+ - Unix-style text pipelines
53
+ - \`grep\`, \`sed\`, \`awk\`, \`find\`, \`xargs\`
54
+
55
+ Use PowerShell for Windows-native workflows:
56
+
57
+ - Windows paths such as \`C:\\...\` or \`D:\\...\`
58
+ - Windows environment variables such as \`$env:USERPROFILE\`
59
+ - \`.exe\`, \`.cmd\`, \`.bat\`, \`.ps1\`
60
+ - process management
61
+ - killing processes by PID or port
62
+ - checking installed commands with \`Get-Command\`
63
+ - Python virtual environments on Windows
64
+ - npm/yarn/pnpm/npx commands that resolve through \`.cmd\` launchers
65
+ - Windows services, registry, or system configuration
66
+ - launching Windows executables such as Godot, Blender, editors, or installers
67
+
68
+ Do not mix Bash syntax and PowerShell syntax in the same command.
69
+
70
+ Prefer \`git diff\` over shell-specific \`diff\` when inspecting repository changes.
71
+
72
+ ## Windows path handling
73
+
74
+ Do not assume Windows paths are valid inside Bash.
75
+
76
+ If a command uses a Windows path such as:
77
+
78
+ \`\`\`txt
79
+ C:\\...
80
+ D:\\...
81
+ \`\`\`
82
+
83
+ use PowerShell.
84
+
85
+ Do not manually convert Windows paths to \`/mnt/c/...\`, \`/c/...\`, or \`/d/...\` unless the active Bash environment has already been verified to support that path style.
86
+
87
+ Do not assume WSL is available.
88
+
89
+ ## Long-running commands
90
+
91
+ Do not use Bash background syntax on Windows:
92
+
93
+ \`\`\`bash
94
+ npm run dev &
95
+ \`\`\`
96
+
97
+ For long-running commands, background servers, file watchers, REPLs, or GUI applications, use the environment-provided Windows process tools when available:
98
+
99
+ - \`win_start_process\`
100
+ - \`win_process_status\`
101
+ - \`win_read_output\`
102
+ - \`win_stop_process\`
103
+ - \`win_list_processes\`
104
+
105
+ For stuck ports, use the environment-provided port tool when available:
106
+
107
+ - \`win_kill_port\`
108
+
109
+ Examples of long-running or blocking commands include:
110
+
111
+ - \`npm run dev\`
112
+ - \`pnpm dev\`
113
+ - \`yarn dev\`
114
+ - \`godot . -e\`
115
+ - local web servers
116
+ - file watchers
117
+ - REPLs
118
+ - GUI applications
119
+
120
+ ## Command availability
121
+
122
+ Do not assume project-specific executable paths or tool names globally.
123
+
124
+ If a command is unavailable, diagnose it before retrying.
125
+
126
+ For PowerShell-native checks, use:
127
+
128
+ \`\`\`powershell
129
+ Get-Command <command-name> -ErrorAction SilentlyContinue
130
+ \`\`\`
131
+
132
+ If the environment provides \`win_which\`, it may also be used for Windows command resolution.
133
+
134
+ For Bash-only tools, use Bash diagnostics only after confirming the command is intended to run in Bash.
135
+
136
+ ## Failure handling
137
+
138
+ When a command fails, do not retry blindly.
139
+
140
+ Identify:
141
+
142
+ 1. Which shell/tool ran it.
143
+ 2. The current working directory.
144
+ 3. The exit code.
145
+ 4. stderr/stdout.
146
+ 5. Whether the command is Windows-native, Unix-like, or environment-provided.
147
+ 6. Whether the path syntax matches the selected shell.
148
+
149
+ Then choose the corrected shell or tool before retrying.`;
48
150
 
49
151
  export default function (pi: ExtensionAPI) {
50
152
  // ── Status bar ──────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gogomi/pi-windows-shell",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "Windows PowerShell and process-management tools for Pi coding agent.",
6
6
  "main": "index.ts",
@@ -11,7 +11,6 @@
11
11
  "paths.ts",
12
12
  "process-registry.ts",
13
13
  "types.ts",
14
- "prompts/windows-shell-policy.md",
15
14
  "tsconfig.json",
16
15
  "README.md",
17
16
  "LICENSE"
@@ -31,9 +30,6 @@
31
30
  "pi": {
32
31
  "extensions": [
33
32
  "./index.ts"
34
- ],
35
- "prompts": [
36
- "./prompts"
37
33
  ]
38
34
  },
39
35
  "dependencies": {
@@ -1,113 +0,0 @@
1
- # Windows Shell Policy
2
-
3
- The environment runs on Windows.
4
-
5
- These rules are always active when choosing how to run commands.
6
-
7
- ## Shell/tool selection
8
-
9
- Use Bash only for Git-oriented and Unix-like repository inspection workflows:
10
-
11
- - `git status`
12
- - `git diff`
13
- - `git log`
14
- - `git grep`
15
- - patch inspection
16
- - Unix-style text pipelines
17
- - `grep`, `sed`, `awk`, `find`, `xargs`
18
-
19
- Use PowerShell for Windows-native workflows:
20
-
21
- - Windows paths such as `C:\...` or `D:\...`
22
- - Windows environment variables such as `$env:USERPROFILE`
23
- - `.exe`, `.cmd`, `.bat`, `.ps1`
24
- - process management
25
- - killing processes by PID or port
26
- - checking installed commands with `Get-Command`
27
- - Python virtual environments on Windows
28
- - npm/yarn/pnpm/npx commands that resolve through `.cmd` launchers
29
- - Windows services, registry, or system configuration
30
- - launching Windows executables such as Godot, Blender, editors, or installers
31
-
32
- Do not mix Bash syntax and PowerShell syntax in the same command.
33
-
34
- Prefer `git diff` over shell-specific `diff` when inspecting repository changes.
35
-
36
- ## Windows path handling
37
-
38
- Do not assume Windows paths are valid inside Bash.
39
-
40
- If a command uses a Windows path such as:
41
-
42
- ```txt
43
- C:\...
44
- D:\...
45
- ```
46
-
47
- use PowerShell.
48
-
49
- Do not manually convert Windows paths to `/mnt/c/...`, `/c/...`, or `/d/...` unless the active Bash environment has already been verified to support that path style.
50
-
51
- Do not assume WSL is available.
52
-
53
- ## Long-running commands
54
-
55
- Do not use Bash background syntax on Windows:
56
-
57
- ```bash
58
- npm run dev &
59
- ```
60
-
61
- For long-running commands, background servers, file watchers, REPLs, or GUI applications, use the environment-provided Windows process tools when available:
62
-
63
- - `win_start_process`
64
- - `win_process_status`
65
- - `win_read_output`
66
- - `win_stop_process`
67
- - `win_list_processes`
68
-
69
- For stuck ports, use the environment-provided port tool when available:
70
-
71
- - `win_kill_port`
72
-
73
- Examples of long-running or blocking commands include:
74
-
75
- - `npm run dev`
76
- - `pnpm dev`
77
- - `yarn dev`
78
- - `godot . -e`
79
- - local web servers
80
- - file watchers
81
- - REPLs
82
- - GUI applications
83
-
84
- ## Command availability
85
-
86
- Do not assume project-specific executable paths or tool names globally.
87
-
88
- If a command is unavailable, diagnose it before retrying.
89
-
90
- For PowerShell-native checks, use:
91
-
92
- ```powershell
93
- Get-Command <command-name> -ErrorAction SilentlyContinue
94
- ```
95
-
96
- If the environment provides `win_which`, it may also be used for Windows command resolution.
97
-
98
- For Bash-only tools, use Bash diagnostics only after confirming the command is intended to run in Bash.
99
-
100
- ## Failure handling
101
-
102
- When a command fails, do not retry blindly.
103
-
104
- Identify:
105
-
106
- 1. Which shell/tool ran it.
107
- 2. The current working directory.
108
- 3. The exit code.
109
- 4. stderr/stdout.
110
- 5. Whether the command is Windows-native, Unix-like, or environment-provided.
111
- 6. Whether the path syntax matches the selected shell.
112
-
113
- Then choose the corrected shell or tool before retrying.