whendone 0.0.0-stage → 1.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 +21 -0
- package/README.md +49 -3
- package/bin/install.js +24 -0
- package/package.json +30 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nischal Masand
|
|
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
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# whendone
|
|
2
|
+
|
|
3
|
+
A Claude Code plugin that puts the computer to sleep or shuts it down once every running Claude Code task has finished. Windows and macOS.
|
|
4
|
+
|
|
5
|
+
Website: https://whendone.vercel.app
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
- Plugin hooks mark each session as running when you send a prompt (`UserPromptSubmit`) and as finished when Claude stops (`Stop`, `StopFailure` for API errors, `SessionEnd`). The markers live in `%LOCALAPPDATA%\claude-autoshutdown` on Windows and in `~/Library/Application Support/whendone` on a Mac.
|
|
9
|
+
- When you activate it, a watcher window waits until no session is running, then counts down 30 s and acts. If a task starts again during the countdown, it goes back to waiting. The countdown shows in a box that stays on top, with **Sleep now** (or **Shut down now**) and **Cancel**.
|
|
10
|
+
- A session whose transcript hasn't changed for 30 min counts as finished. This catches interrupted or crashed sessions, which never fire `Stop`.
|
|
11
|
+
- It only acts after it has seen at least one task running since you activated it. Activating from inside Claude counts that session too, so activating with nothing else running sleeps the computer about 30 seconds later.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
```sh
|
|
15
|
+
npx whendone
|
|
16
|
+
```
|
|
17
|
+
Run it in PowerShell or Terminal, then restart Claude Code. It adds this repo as a plugin marketplace and installs the plugin for your system.
|
|
18
|
+
|
|
19
|
+
Without npm, run these instead:
|
|
20
|
+
```sh
|
|
21
|
+
claude plugin marketplace add nischal-masand/whendone
|
|
22
|
+
claude plugin install whendone@whendone # Windows
|
|
23
|
+
claude plugin install whendone-mac@whendone # macOS
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The two are separate plugins in this one marketplace: the Windows plugin is the repo root, the Mac plugin is `mac/`. Their hooks call PowerShell and `sh` respectively, and Claude Code can't limit a hook to one system.
|
|
27
|
+
|
|
28
|
+
To work on a local copy, add the folder itself as the marketplace (`claude plugin marketplace add <path>`). The plugin runs from a copy in `~/.claude/plugins/cache`, so after editing files, bump `version` in the plugin's `.claude-plugin/plugin.json` and run `claude plugin update whendone@whendone` (or `whendone-mac@whendone`).
|
|
29
|
+
|
|
30
|
+
## Use
|
|
31
|
+
- In any Claude Code session: `/whendone-sleep` or `/whendone-shutdown`. You can queue it behind a running task in the same session.
|
|
32
|
+
- Add `push` to commit and push the work first (`/whendone-sleep push`), or `commit` to commit without pushing. Claude saves the repo of the working folder when the command runs, so queue it behind your last prompt. It never force-pushes and leaves out files that look like secrets.
|
|
33
|
+
- Or double-click **Sleep when done** / **Shutdown when done**: the `.cmd` files in this folder on Windows, the `.command` files in `mac/` on a Mac.
|
|
34
|
+
- To cancel, click **Cancel** in the countdown box, close the watcher window, or press Ctrl+C in it.
|
|
35
|
+
|
|
36
|
+
Windows options: `autoshutdown.ps1 -Action Sleep|Shutdown -CountdownSeconds 30 -StaleMinutes 30 -DryRun -NoDialog` (`-NoDialog` keeps the countdown in the console)
|
|
37
|
+
|
|
38
|
+
Mac options: `mac/whendone.sh sleep|shutdown [--dry-run]`, with `WHENDONE_COUNTDOWN=30`, `WHENDONE_STALE_MINUTES=30` and `WHENDONE_NODIALOG=1` (countdown in the Terminal window instead of a box) in the environment.
|
|
39
|
+
|
|
40
|
+
`-DryRun` / `--dry-run` prints what it would do instead of doing it.
|
|
41
|
+
|
|
42
|
+
## On a Mac
|
|
43
|
+
- The watcher opens in Terminal. While it waits it runs `caffeinate -i`, so the Mac doesn't fall asleep on its own before the tasks finish. Closing a MacBook's lid still sleeps it.
|
|
44
|
+
- Sleep uses `pmset sleepnow` and needs no permission. Shutdown asks System Events to shut down: the first time, macOS asks to let Terminal control System Events. The watcher asks when you activate it, not when it acts. If it was declined, allow it in System Settings > Privacy & Security > Automation. Apps with unsaved work can still stop the shutdown.
|
|
45
|
+
- Needs macOS 12 or later for its JSON parsing (`plutil`). Older versions fall back to `sed`.
|
|
46
|
+
|
|
47
|
+
## Tests
|
|
48
|
+
- `test.ps1` (Windows) and `sh mac/test.sh` (macOS, also runs in Git Bash) drive the hooks and a dry-run watcher. They never sleep or shut down the computer.
|
|
49
|
+
- GitHub Actions runs both on every push (`.github/workflows/test.yml`).
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// One-command install: npx whendone
|
|
3
|
+
// Adds this repo as a Claude Code plugin marketplace, then installs the plugin from it.
|
|
4
|
+
const { spawnSync } = require('node:child_process');
|
|
5
|
+
|
|
6
|
+
// Commands are fixed strings, so running them through the shell is safe (needed to find claude.cmd on Windows).
|
|
7
|
+
const run = (cmd, quiet) => spawnSync(cmd, { shell: true, stdio: quiet ? 'ignore' : 'inherit' }).status;
|
|
8
|
+
|
|
9
|
+
if (run('claude --version', true) !== 0) {
|
|
10
|
+
console.error('Claude Code is not installed or not on PATH. Install it first: https://claude.com/claude-code');
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Fails harmlessly when the marketplace was added before; the update then fetches its latest version.
|
|
15
|
+
run('claude plugin marketplace add nischal-masand/whendone');
|
|
16
|
+
run('claude plugin marketplace update whendone');
|
|
17
|
+
// One plugin per system: their hooks call PowerShell on Windows and sh on a Mac
|
|
18
|
+
const plugin = process.platform === 'darwin' ? 'whendone-mac' : 'whendone';
|
|
19
|
+
if (run(`claude plugin install ${plugin}@whendone`) !== 0) process.exit(1);
|
|
20
|
+
// Running npx whendone again also upgrades an older install (a no-op when it is current)
|
|
21
|
+
run(`claude plugin update ${plugin}@whendone`);
|
|
22
|
+
|
|
23
|
+
console.log('\nInstalled. Restart Claude Code, then type /whendone-sleep or /whendone-shutdown in any session.');
|
|
24
|
+
console.log('Add push to save your work to git first: /whendone-sleep push');
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "whendone",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "whendone",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Sleep or shut down Windows or a Mac once every running Claude Code task has finished.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"whendone": "bin/install.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/"
|
|
10
|
+
],
|
|
11
|
+
"os": [
|
|
12
|
+
"win32",
|
|
13
|
+
"darwin"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"claude-code",
|
|
17
|
+
"claude-code-plugin",
|
|
18
|
+
"windows",
|
|
19
|
+
"macos",
|
|
20
|
+
"sleep",
|
|
21
|
+
"shutdown"
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/nischal-masand/whendone.git"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/nischal-masand/whendone",
|
|
28
|
+
"author": "Nischal Masand (https://github.com/nischal-masand)",
|
|
29
|
+
"license": "MIT"
|
|
30
|
+
}
|