@gogomi/pi-windows-shell 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Gogomy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # pi-windows-shell — Pi Extension
2
+
3
+ [![npm](https://img.shields.io/npm/v/@gogomi/pi-windows-shell)](https://www.npmjs.com/package/@gogomi/pi-windows-shell)
4
+
5
+ Windows PowerShell and process-management extension for [Pi Agent](https://pi.dev). Gives Pi explicit tools for PowerShell execution and long-running process management on Windows, while keeping the built-in `bash` tool fully functional for Git and Unix-like workflows.
6
+
7
+ ## Features
8
+
9
+ - **Foreground PowerShell** — Windows paths, `$env` variables, `.exe`/`.cmd`/`.bat`/`.ps1`, system inspection
10
+ - **Background process lifecycle** — start, monitor, read output, stop, and list detached processes
11
+ - **Port management** — find and kill processes by TCP port
12
+ - **Command discovery** — locate Windows commands with `Get-Command`
13
+ - **Persistent process registry** — survives Pi restarts (`%LOCALAPPDATA%\pi-windows-shell\`)
14
+ - **Automatic shell policy** — injected into every system prompt, guides Pi on Bash vs PowerShell usage
15
+ - **Status bar** — shows discovered PowerShell version
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pi install npm:@gogomi/pi-windows-shell
21
+ ```
22
+
23
+ Reload Pi after install: `/reload`
24
+
25
+ ## Usage
26
+
27
+ ### Slash Commands (you)
28
+
29
+ ```txt
30
+ /win-shell-info → discovered PowerShell, registry path, logs path
31
+ /win-processes → tracked background processes
32
+ /win-cleanup → remove stale registry entries
33
+ ```
34
+
35
+ ### Agent Tools (called automatically by the agent)
36
+
37
+ | Tool | Description |
38
+ |------|-------------|
39
+ | `powershell` | Run a foreground PowerShell command (120s timeout, 50KB/2000 lines) |
40
+ | `win_start_process` | Start a background process, output logged to file |
41
+ | `win_process_status` | Check if a process is alive by ID or PID |
42
+ | `win_read_output` | Read tail of a background process log |
43
+ | `win_stop_process` | Stop a process tree by ID or PID |
44
+ | `win_kill_port` | Find and kill processes listening on a TCP port |
45
+ | `win_which` | Discover command paths with `Get-Command` |
46
+ | `win_list_processes` | List tracked background processes |
47
+ | `win_cleanup_processes` | Remove stale registry entries and old logs |
48
+
49
+ ## Shell policy
50
+
51
+ The extension automatically injects a shell usage policy into every system prompt. The policy covers:
52
+
53
+ - **Bash** → Git workflows, Unix pipelines, `grep`/`sed`/`awk`
54
+ - **PowerShell** → Windows paths, `$env`, `.exe`/`.cmd`/`.bat`, process management, Windows services
55
+ - **Path handling** → don't convert `C:\` to `/mnt/c/`, don't assume WSL
56
+ - **Long-running** → use `win_start_process` instead of `npm run dev &`
57
+ - **Failure diagnosis** → identify shell, cwd, exit code, stderr before retrying
58
+
59
+ See `prompts/windows-shell-policy.md` for the full policy.
60
+
61
+ ## Structure
62
+
63
+ ```
64
+ index.ts ← Pi extension (9 tools + 3 commands + policy injection)
65
+ shell.ts ← PowerShell discovery and foreground/background execution
66
+ process-registry.ts ← Persistent JSON registry for managed processes
67
+ output.ts ← Output truncation and tail reading
68
+ paths.ts ← Registry and log path helpers
69
+ types.ts ← Shared TypeScript interfaces
70
+ prompts/
71
+ windows-shell-policy.md ← Injected shell policy
72
+ ```
73
+
74
+ ## Requirements
75
+
76
+ - Node.js ≥ 18
77
+ - Windows with PowerShell 5+ (PowerShell 7 recommended)