git-watchtower 1.0.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 +21 -0
- package/README.md +331 -0
- package/bin/git-watchtower.js +2966 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
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,331 @@
|
|
|
1
|
+
# Git Watchtower
|
|
2
|
+
|
|
3
|
+
Monitor and switch between git branches in real-time. Built for working with web based AI coding agents, like Claude Code Web & Codex.
|
|
4
|
+
|
|
5
|
+
- **Live branch monitoring** - Watches your remote for new commits, branches, and deletions
|
|
6
|
+
- **Instant notifications** - Visual and audio alerts when any branch is updated
|
|
7
|
+
- **Quick switching** - Preview changes and jump to any branch with a keypress
|
|
8
|
+
- **Auto-pull** - Automatically pulls when your current branch has remote changes
|
|
9
|
+
- **Optional dev server** - Built-in static server with live reload, or run your own command (Next.js. Nuxt.js, Vite, etc)
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## Why Git Watchtower?
|
|
14
|
+
|
|
15
|
+
When you're using AI coding agents on the web (Claude, OpenAI Codex, etc.) they create branches and push commits while you're not looking. You end up with multiple branches to check on and no easy way to know when they've been updated or what changed.
|
|
16
|
+
|
|
17
|
+
Git Watchtower watches your remote and notifies you when branches are updated. Preview what changed, switch with a keypress, undo if needed.
|
|
18
|
+
|
|
19
|
+
Also works for human collaborators, but the primary use case is keeping tabs on AI agents coding on different branches.
|
|
20
|
+
|
|
21
|
+
Git Watchtower supports **three server modes** to fit your workflow:
|
|
22
|
+
- **Static Site Mode** - Built-in server with live reload for HTML/CSS/JS
|
|
23
|
+
- **Custom Server Command Mode** - Run your own dev server (Next.js, Vite, Nuxt, etc.)
|
|
24
|
+
- **No Server Mode** - Branch monitoring only (ideal for watching multiple AI agents)
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- **Full Terminal UI** - Clean interface with box drawing and colors
|
|
29
|
+
- **Activity Sparklines** - 7-day commit history visualization for each branch
|
|
30
|
+
- **Branch Search** - Quickly filter branches by name with `/`
|
|
31
|
+
- **Preview Pane** - See recent commits and changed files before switching
|
|
32
|
+
- **Session History** - Undo branch switches with `u`
|
|
33
|
+
- **Visual Alerts** - Flash notifications when updates arrive
|
|
34
|
+
- **Audio Notifications** - Optional sound alerts (works on macOS, Linux, Windows)
|
|
35
|
+
- **Auto-Pull** - Automatically pulls when your current branch has updates (configurable)
|
|
36
|
+
- **Merge Conflict Detection** - Warns you when auto-pull fails
|
|
37
|
+
- **Flexible Server Modes** - Static site, custom server command, or no server
|
|
38
|
+
- **Server Log View** - Press `l` to view your dev server output (custom server command mode)
|
|
39
|
+
- **Server Restart** - Press `R` to restart your dev server (custom server command mode)
|
|
40
|
+
- **Configurable Remote** - Works with any git remote name (not just `origin`)
|
|
41
|
+
- **Zero Dependencies** - Uses only Node.js built-in modules
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Global install (recommended)
|
|
47
|
+
npm install -g git-watchtower
|
|
48
|
+
|
|
49
|
+
# Or run directly with npx
|
|
50
|
+
npx git-watchtower
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Navigate to any git repository
|
|
57
|
+
cd your-project
|
|
58
|
+
|
|
59
|
+
# Start Git Watchtower
|
|
60
|
+
git-watchtower
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
On first run, you'll be guided through a configuration wizard.
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Run with default settings (or saved config)
|
|
69
|
+
git-watchtower
|
|
70
|
+
|
|
71
|
+
# Run without dev server (branch monitoring only)
|
|
72
|
+
git-watchtower --no-server
|
|
73
|
+
|
|
74
|
+
# Specify a custom port for the dev server
|
|
75
|
+
git-watchtower --port 8080
|
|
76
|
+
|
|
77
|
+
# Re-run the configuration wizard
|
|
78
|
+
git-watchtower --init
|
|
79
|
+
|
|
80
|
+
# Show version
|
|
81
|
+
git-watchtower --version
|
|
82
|
+
|
|
83
|
+
# Show help
|
|
84
|
+
git-watchtower --help
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Server Modes
|
|
88
|
+
|
|
89
|
+
### Static Site Mode (Default)
|
|
90
|
+
Serves static files with automatic live reload. Good for static HTML/CSS/JS sites, projects without a build step, quick prototyping.
|
|
91
|
+
|
|
92
|
+
### Custom Server Command Mode
|
|
93
|
+
Runs your own dev server command (`next dev`, `npm run dev`, `vite`, etc.). Press `l` to view server logs, `R` to restart the server.
|
|
94
|
+
|
|
95
|
+
### No Server Mode
|
|
96
|
+
Branch monitoring only. Use this when watching AI agents push to multiple branches, or when you have your own dev server running separately.
|
|
97
|
+
|
|
98
|
+
## Configuration
|
|
99
|
+
|
|
100
|
+
On first run, Git Watchtower prompts you to configure:
|
|
101
|
+
|
|
102
|
+
| Setting | Description | Default |
|
|
103
|
+
|---------|-------------|---------|
|
|
104
|
+
| Server mode | static, command, or none | static |
|
|
105
|
+
| Port | Server port number | 3000 |
|
|
106
|
+
| Static directory | Directory to serve (static site mode) | public |
|
|
107
|
+
| Command | Dev server command (custom server command mode) | npm run dev |
|
|
108
|
+
| Restart on switch | Restart server on branch switch | true |
|
|
109
|
+
| Auto-pull | Auto-pull when current branch has updates | true |
|
|
110
|
+
| Polling interval | How often to check for git updates | 5 seconds |
|
|
111
|
+
| Sound notifications | Audio alerts for updates | true |
|
|
112
|
+
| Visible branches | Number of branches shown in list | 7 |
|
|
113
|
+
|
|
114
|
+
Settings are saved to `.watchtowerrc.json` in your project directory.
|
|
115
|
+
|
|
116
|
+
### Example Configuration
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"server": {
|
|
121
|
+
"mode": "command",
|
|
122
|
+
"command": "npm run dev",
|
|
123
|
+
"port": 3000,
|
|
124
|
+
"restartOnSwitch": true,
|
|
125
|
+
"staticDir": "public"
|
|
126
|
+
},
|
|
127
|
+
"remoteName": "origin",
|
|
128
|
+
"autoPull": true,
|
|
129
|
+
"gitPollInterval": 5000,
|
|
130
|
+
"soundEnabled": true,
|
|
131
|
+
"visibleBranches": 7
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Environment Variables
|
|
136
|
+
|
|
137
|
+
You can also use environment variables:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
PORT=8080 git-watchtower
|
|
141
|
+
GIT_POLL_INTERVAL=10000 git-watchtower
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Keyboard Controls
|
|
145
|
+
|
|
146
|
+
### Navigation
|
|
147
|
+
| Key | Action |
|
|
148
|
+
|-----|--------|
|
|
149
|
+
| `↑` / `k` | Move selection up |
|
|
150
|
+
| `↓` / `j` | Move selection down |
|
|
151
|
+
| `Enter` | Switch to selected branch |
|
|
152
|
+
| `/` | Search/filter branches |
|
|
153
|
+
| `Esc` | Clear search / Close modal / Quit |
|
|
154
|
+
|
|
155
|
+
### Actions
|
|
156
|
+
| Key | Action |
|
|
157
|
+
|-----|--------|
|
|
158
|
+
| `v` | Preview selected branch (commits & files) |
|
|
159
|
+
| `h` | Show switch history |
|
|
160
|
+
| `u` | Undo last branch switch |
|
|
161
|
+
| `p` | Force pull current branch |
|
|
162
|
+
| `f` | Fetch all branches + refresh sparklines |
|
|
163
|
+
|
|
164
|
+
### Server Controls
|
|
165
|
+
| Key | Mode | Action |
|
|
166
|
+
|-----|------|--------|
|
|
167
|
+
| `r` | Static site | Force reload all browsers |
|
|
168
|
+
| `l` | Custom server command | View server logs |
|
|
169
|
+
| `R` | Custom server command | Restart dev server |
|
|
170
|
+
|
|
171
|
+
### Display
|
|
172
|
+
| Key | Action |
|
|
173
|
+
|-----|--------|
|
|
174
|
+
| `s` | Toggle sound notifications |
|
|
175
|
+
| `i` | Show server/status info |
|
|
176
|
+
| `1-0` | Set visible branch count (1-10) |
|
|
177
|
+
| `+` / `-` | Increase/decrease visible branches |
|
|
178
|
+
|
|
179
|
+
### Quit
|
|
180
|
+
| Key | Action |
|
|
181
|
+
|-----|--------|
|
|
182
|
+
| `q` | Quit |
|
|
183
|
+
| `Ctrl+C` | Quit |
|
|
184
|
+
|
|
185
|
+
## Status Indicators
|
|
186
|
+
|
|
187
|
+
| Badge | Meaning |
|
|
188
|
+
|-------|---------|
|
|
189
|
+
| `★ CURRENT` | Currently checked-out branch |
|
|
190
|
+
| `✦ NEW` | Branch created since Watchtower started |
|
|
191
|
+
| `↓ UPDATES` | Remote has new commits to pull |
|
|
192
|
+
| `✗ DELETED` | Branch was deleted from remote |
|
|
193
|
+
| `NO-SERVER` | Running in branch-monitor-only mode |
|
|
194
|
+
| `SERVER CRASHED` | Dev server process crashed (custom server command mode) |
|
|
195
|
+
| `OFFLINE` | Network connectivity issues detected |
|
|
196
|
+
| `DETACHED HEAD` | Not on a branch (commit checkout) |
|
|
197
|
+
| `MERGE CONFLICT` | Auto-pull failed due to conflicts |
|
|
198
|
+
|
|
199
|
+
## Requirements
|
|
200
|
+
|
|
201
|
+
- **Node.js** 14.0.0 or higher
|
|
202
|
+
- **Git** installed and in PATH
|
|
203
|
+
- **Git remote** configured (any name, defaults to `origin`)
|
|
204
|
+
- **Terminal** with ANSI color support
|
|
205
|
+
|
|
206
|
+
## How It Works
|
|
207
|
+
|
|
208
|
+
1. **Polling**: Git Watchtower runs `git fetch` periodically to check for updates
|
|
209
|
+
2. **Detection**: Compares commit hashes to detect new commits, branches, and deletions
|
|
210
|
+
3. **Auto-pull**: When your current branch has remote updates, it pulls automatically (if enabled)
|
|
211
|
+
4. **Server**: Depending on mode, either serves static files, runs your command, or does nothing
|
|
212
|
+
5. **Live Reload**: In static site mode, notifies connected browsers via SSE when files change
|
|
213
|
+
|
|
214
|
+
## Troubleshooting
|
|
215
|
+
|
|
216
|
+
### "Git is not installed or not in PATH"
|
|
217
|
+
Git Watchtower requires Git. Install it from: https://git-scm.com/downloads
|
|
218
|
+
|
|
219
|
+
### "No Git remote configured"
|
|
220
|
+
Git Watchtower requires a remote to watch. Add one with:
|
|
221
|
+
```bash
|
|
222
|
+
git remote add origin <repository-url>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Using a different remote name
|
|
226
|
+
If your remote isn't called `origin`, update your config:
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"remoteName": "upstream"
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Port already in use
|
|
234
|
+
Try a different port:
|
|
235
|
+
```bash
|
|
236
|
+
git-watchtower -p 3001
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Slow fetches / High latency
|
|
240
|
+
Git Watchtower will automatically reduce polling frequency on slow networks. You can also increase the interval in your config.
|
|
241
|
+
|
|
242
|
+
### Sound not working
|
|
243
|
+
- **macOS**: Uses system sounds via `afplay`
|
|
244
|
+
- **Linux**: Requires PulseAudio (`paplay`) or ALSA (`aplay`)
|
|
245
|
+
- **Windows**: Uses terminal bell
|
|
246
|
+
|
|
247
|
+
Toggle sound with `s` or set `"soundEnabled": false` in config.
|
|
248
|
+
|
|
249
|
+
### Server crashes immediately (custom server command mode)
|
|
250
|
+
- Check that your command works when run directly
|
|
251
|
+
- View logs with `l` to see error messages
|
|
252
|
+
- Try restarting with `R`
|
|
253
|
+
|
|
254
|
+
## Contributing
|
|
255
|
+
|
|
256
|
+
Contributions are welcome! There are several ways to contribute to Git Watchtower:
|
|
257
|
+
|
|
258
|
+
### Reporting Bugs
|
|
259
|
+
|
|
260
|
+
If you find a bug, please [open an issue](https://github.com/drummel/git-watchtower/issues/new) on GitHub with:
|
|
261
|
+
- A clear, descriptive title
|
|
262
|
+
- Steps to reproduce the issue
|
|
263
|
+
- Expected vs actual behavior
|
|
264
|
+
- Your environment (OS, Node.js version, terminal)
|
|
265
|
+
- Any relevant error messages or screenshots
|
|
266
|
+
|
|
267
|
+
### Requesting Features
|
|
268
|
+
|
|
269
|
+
Have an idea to improve Git Watchtower? [Submit a feature request](https://github.com/drummel/git-watchtower/issues/new) with:
|
|
270
|
+
- A clear description of the feature
|
|
271
|
+
- The problem it would solve or use case it addresses
|
|
272
|
+
- Any implementation ideas (optional)
|
|
273
|
+
|
|
274
|
+
### Submitting Pull Requests
|
|
275
|
+
|
|
276
|
+
1. Fork the repository
|
|
277
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
278
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
279
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
280
|
+
5. Open a Pull Request
|
|
281
|
+
|
|
282
|
+
Please ensure your PR:
|
|
283
|
+
- Includes a clear description of the changes
|
|
284
|
+
- Maintains the zero-dependency philosophy (Node.js built-ins only)
|
|
285
|
+
- Works across platforms (macOS, Linux, Windows) when applicable
|
|
286
|
+
|
|
287
|
+
## Development
|
|
288
|
+
|
|
289
|
+
### Local Installation
|
|
290
|
+
|
|
291
|
+
For local development and testing:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Clone the repository
|
|
295
|
+
git clone https://github.com/drummel/git-watchtower.git
|
|
296
|
+
cd git-watchtower
|
|
297
|
+
|
|
298
|
+
# Option 1: npm link (recommended)
|
|
299
|
+
# Creates a global symlink - changes take effect immediately
|
|
300
|
+
npm link
|
|
301
|
+
|
|
302
|
+
# Now you can run from any git repository:
|
|
303
|
+
git-watchtower
|
|
304
|
+
|
|
305
|
+
# Option 2: Run directly without installing
|
|
306
|
+
node bin/git-watchtower.js
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### After Making Code Changes
|
|
310
|
+
|
|
311
|
+
| Install Method | Update Process |
|
|
312
|
+
|----------------|----------------|
|
|
313
|
+
| `npm link` | Nothing - changes apply immediately |
|
|
314
|
+
| `npm install -g .` | Run `npm install -g .` again |
|
|
315
|
+
| Direct `node bin/...` | Nothing - always runs current code |
|
|
316
|
+
|
|
317
|
+
### Unlinking
|
|
318
|
+
|
|
319
|
+
To remove the global symlink:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
npm unlink -g git-watchtower
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## License
|
|
326
|
+
|
|
327
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
328
|
+
|
|
329
|
+
## Acknowledgments
|
|
330
|
+
|
|
331
|
+
- Built with Node.js built-in modules only (no external dependencies)
|