|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +# ⚡ TSG — Terminal State Guard |
| 4 | + |
| 5 | +### Cross-platform CLI for Copilot Performance Boosting, Safe Monitoring & Session Recovery |
| 6 | + |
| 7 | +[](https://www.nuget.org/packages/TerminalStateGuard) |
| 8 | +[](LICENSE) |
| 9 | +[](https://dotnet.microsoft.com) |
| 10 | +[]() |
| 11 | + |
| 12 | +**One command to install. Keyboard shortcuts ready. Zero config.** |
| 13 | + |
| 14 | +[Installation](#-installation) · [Commands](#-commands) · [Monitor](#-safe-monitor) · [Recovery](#-session-recovery) · [Doctor](#-doctor) |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +</div> |
| 19 | + |
| 20 | +## 🚀 Installation |
| 21 | + |
| 22 | +```bash |
| 23 | +dotnet tool install -g TerminalStateGuard |
| 24 | +tsg install |
| 25 | +``` |
| 26 | + |
| 27 | +**Done.** Reopen your terminal — shortcuts and integration are active. |
| 28 | + |
| 29 | +### What `tsg install` does: |
| 30 | + |
| 31 | +| Platform | Action | |
| 32 | +|----------|--------| |
| 33 | +| **Windows** | Installs [Windows Terminal Fragment](https://learn.microsoft.com/en-us/windows/terminal/json-fragment-extensions) for native shortcut integration | |
| 34 | +| **Windows** | Configures PSReadLine keyboard shortcuts in PowerShell profile | |
| 35 | +| **Linux** | Adds shell aliases and keybindings to `.bashrc`/`.zshrc` | |
| 36 | +| **Both** | Deploys monitoring scripts to `~/.tsg/` | |
| 37 | + |
| 38 | +## ⌨️ Commands |
| 39 | + |
| 40 | +```bash |
| 41 | +tsg install # Setup scripts, shortcuts & terminal integration |
| 42 | +tsg boost # ⚡ Elevate Copilot process priority (Admin/sudo) |
| 43 | +tsg monitor # 📊 Safe live monitor with diagnostics |
| 44 | +tsg status # 📋 Quick health check |
| 45 | +tsg recover # 🔄 Recover terminal tabs + Copilot sessions |
| 46 | +tsg restore # 🔄 Revert all priority changes |
| 47 | +tsg doctor # 🩺 Diagnose environment issues |
| 48 | +tsg uninstall # 🗑️ Remove configuration |
| 49 | +``` |
| 50 | + |
| 51 | +### Keyboard Shortcuts |
| 52 | + |
| 53 | +| Shortcut | Action | |
| 54 | +|----------|--------| |
| 55 | +| `Ctrl+Alt+B` | Boost | |
| 56 | +| `Ctrl+Alt+M` | Monitor | |
| 57 | +| `Ctrl+Alt+S` | Status | |
| 58 | +| `Ctrl+Alt+F` | Recover | |
| 59 | +| `Ctrl+Alt+R` | Restore | |
| 60 | + |
| 61 | +## 📊 Safe Monitor |
| 62 | + |
| 63 | +**100% read-only** — never modifies Copilot's internal files. |
| 64 | + |
| 65 | +``` |
| 66 | + ⚡ TSG MONITOR 06:30:00 [🟢 BOOSTED] [4/4] |
| 67 | + ══════════════════════════════════════════════════════ |
| 68 | + PID 221120 | copilot | 180 MB | H: 234 | Δ 0.3s | 🟢 IDLE |
| 69 | + 📂 MyProject — Implement auth system |
| 70 | + 📄 Events: 2.1MB | Last: assistant.turn_end | ok |
| 71 | + PID 52300 | copilot-ls | 16 MB | H: 120 | Δ 0.0s | 🟢 IDLE |
| 72 | + 🟣 Visual Studio |
| 73 | + ══════════════════════════════════════════════════════ |
| 74 | + TOTAL: 196 MB | CPU: 125.3s | Threads: 31 |
| 75 | +``` |
| 76 | + |
| 77 | +### Diagnostic Indicators |
| 78 | + |
| 79 | +| State | Meaning | Action | |
| 80 | +|-------|---------|--------| |
| 81 | +| 🟢 IDLE | Healthy, idle | None | |
| 82 | +| 🟡 ACTIVE | Processing | Wait | |
| 83 | +| 🔴 HIGH CPU | Heavy computation | Wait or close → resume | |
| 84 | +| 🔴 HANDLE LEAK | events.jsonl too large | Close tab → `copilot --resume` | |
| 85 | +| ❄️ STUCK | Turn never completed | Close tab → resume (auto-recovers) | |
| 86 | + |
| 87 | +## 🔄 Session Recovery |
| 88 | + |
| 89 | +```bash |
| 90 | +tsg recover |
| 91 | +``` |
| 92 | + |
| 93 | +Scans Windows Terminal state + Copilot sessions and reopens tabs with `copilot --resume`: |
| 94 | + |
| 95 | +``` |
| 96 | + 🔄 Session Recovery |
| 97 | + ✅ 8 tabs (5 copilot) |
| 98 | +
|
| 99 | + [1] 🤖 MyProject (Win 1) |
| 100 | + 💬 Implement auth system |
| 101 | + [2] 📂 Documents (Win 1) |
| 102 | + [3] 🤖 WebApp (Win 2) |
| 103 | + 💬 Fix DllNotFoundException |
| 104 | +``` |
| 105 | + |
| 106 | +## 🩺 Doctor |
| 107 | + |
| 108 | +```bash |
| 109 | +tsg doctor |
| 110 | +``` |
| 111 | + |
| 112 | +Checks environment, finds stuck sessions, validates setup: |
| 113 | + |
| 114 | +``` |
| 115 | + 🩺 TSG Doctor — Environment Check |
| 116 | +
|
| 117 | + ✅ .NET 10.0.0 |
| 118 | + ✅ Shell: C:\Program Files\PowerShell\7\pwsh.exe |
| 119 | + ✅ TSG dir: C:\Users\you\.tsg |
| 120 | + ✅ Copilot sessions: 12 |
| 121 | + ⚠️ 1 session(s) > 20MB — may cause slowness |
| 122 | + ✅ Windows Terminal Fragment installed |
| 123 | + ✅ Terminal state: 2 windows, 8 tabs |
| 124 | +
|
| 125 | + 🎉 All checks passed! |
| 126 | +``` |
| 127 | + |
| 128 | +## 🛡️ Safety |
| 129 | + |
| 130 | +> **TSG never modifies Copilot's internal files.** |
| 131 | +
|
| 132 | +- ✅ All monitoring is **read-only** — only reads metadata |
| 133 | +- ✅ Never deletes, trims, or edits `events.jsonl` |
| 134 | +- ✅ Session recovery uses native `copilot --resume` |
| 135 | +- ✅ Diagnostics show root cause + safe manual recommendations |
| 136 | + |
| 137 | +## ⚡ Architecture |
| 138 | + |
| 139 | +``` |
| 140 | +tsg (dotnet tool) |
| 141 | + ├── Platform/ |
| 142 | + │ ├── IPlatformHost.cs — Cross-platform abstraction |
| 143 | + │ ├── WindowsHost.cs — Windows Terminal Fragment + PSReadLine |
| 144 | + │ └── LinuxHost.cs — bash/zsh aliases + keybindings |
| 145 | + ├── Scripts/ |
| 146 | + │ ├── windows/*.ps1 — PowerShell monitoring scripts |
| 147 | + │ └── linux/*.sh — Bash monitoring scripts |
| 148 | + ├── CommandRegistry.cs — Lambda-based command routing |
| 149 | + ├── Installer.cs — Script deployment + profile config |
| 150 | + ├── ScriptRunner.cs — Cross-platform script execution |
| 151 | + └── Diagnostics.cs — Environment health checks |
| 152 | +``` |
| 153 | + |
| 154 | +**Built with:** .NET 10 · C# 14 · Windows Terminal Fragments API |
| 155 | + |
| 156 | +## 📦 Requirements |
| 157 | + |
| 158 | +| Platform | Requirements | |
| 159 | +|----------|-------------| |
| 160 | +| **Windows** | Windows Terminal, PowerShell 7+, .NET 10 Runtime | |
| 161 | +| **Linux** | bash/zsh, .NET 10 Runtime | |
| 162 | +| **Both** | GitHub Copilot CLI (`npm i -g @github/copilot`) | |
| 163 | + |
| 164 | +## 🗑️ Uninstall |
| 165 | + |
| 166 | +```bash |
| 167 | +tsg uninstall |
| 168 | +dotnet tool uninstall -g TerminalStateGuard |
| 169 | +``` |
| 170 | + |
| 171 | +## 📄 License |
| 172 | + |
| 173 | +[MIT](LICENSE) — Made with ⚡ by [sbay-dev](https://github.com/sbay-dev) |
0 commit comments