@lilmgenius/win-hooks 1.11.0 → 1.12.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/README.md +25 -67
- package/bin/win-hooks.mjs +49 -12
- package/package.json +4 -12
- package/src/verify.mjs +1 -2
package/README.md
CHANGED
|
@@ -6,31 +6,21 @@
|
|
|
6
6
|
|
|
7
7
|
**Windows auto-patcher for vibe coders.**
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
win-hooks repairs the plugin hooks that break on your Windows machine.<br>
|
|
10
|
+
Automatically, at every session start, and again for ones added later.
|
|
11
11
|
|
|
12
|
-
[](https://www.microsoft.com/windows)
|
|
13
|
+
[](https://docs.anthropic.com/en/docs/claude-code)
|
|
14
|
+
[](https://developers.openai.com/codex)
|
|
15
|
+
[](LICENSE)
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Install
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
SessionStart hook error: /bin/bash: command not found
|
|
25
|
-
PreToolUse hook error: scripts/check.sh: No such file or directory
|
|
26
|
-
PostToolUse hook error: semgrep: command not found
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
You installed a plugin. It works fine for everyone on a Mac. On your machine it greets you with red text every single time you open a session.
|
|
30
|
-
|
|
31
|
-
Nothing is broken on your end. Almost every plugin is written and tested on macOS or Linux, so its hooks quietly assume Unix tools that Windows does not have. You are not supposed to fix that by hand. **win-hooks does it for you.**
|
|
32
|
-
|
|
33
|
-
## Install it once, forget it exists
|
|
23
|
+
Pick your tool and paste one line.
|
|
34
24
|
|
|
35
25
|
**Claude Code**
|
|
36
26
|
|
|
@@ -44,16 +34,19 @@ claude plugin marketplace add LilMGenius/win-hooks && claude plugin install win-
|
|
|
44
34
|
codex plugin marketplace add LilMGenius/win-hooks && codex plugin add win-hooks@win-hooks
|
|
45
35
|
```
|
|
46
36
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Prefer a one-shot fix, or need it in CI? Skip the plugin and run it directly:
|
|
37
|
+
**Neither, just fix my plugins now**
|
|
50
38
|
|
|
51
39
|
```bash
|
|
52
|
-
npx @lilmgenius/win-hooks
|
|
53
|
-
npx @lilmgenius/win-hooks status # show what it found last time
|
|
40
|
+
npx @lilmgenius/win-hooks
|
|
54
41
|
```
|
|
55
42
|
|
|
56
|
-
|
|
43
|
+
That's the whole setup. No config, no flags, nothing to remember.
|
|
44
|
+
|
|
45
|
+
You need Windows 10/11 and [Git for Windows](https://git-scm.com/download/win). Node.js already comes with Claude Code and Codex.
|
|
46
|
+
|
|
47
|
+
## What it fixes
|
|
48
|
+
|
|
49
|
+
You installed a plugin. It works fine for everyone on a Mac. On your machine it greets you with red text every time you open a session.
|
|
57
50
|
|
|
58
51
|
| The error you see | What was wrong |
|
|
59
52
|
|---|---|
|
|
@@ -64,58 +57,23 @@ npx @lilmgenius/win-hooks status # show what it found last time
|
|
|
64
57
|
| `JSON Parse error: Unrecognized token` | An invisible byte (BOM) at the top of a config file |
|
|
65
58
|
| `Cannot find module 'C:\Users...'` | Backslashes in a path getting eaten before the hook runs |
|
|
66
59
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
## Staying fixed
|
|
60
|
+
None of that is your fault. Almost every plugin is written and tested on macOS or Linux, so its hooks assume Unix tools that Windows does not have.
|
|
70
61
|
|
|
71
|
-
|
|
72
|
-
flowchart LR
|
|
73
|
-
A[scan installed plugins] --> B[patch broken hooks] --> C[verify & auto-repair]
|
|
74
|
-
```
|
|
62
|
+
## How it stays fixed
|
|
75
63
|
|
|
76
|
-
|
|
64
|
+
win-hooks repairs your plugins at every session start, including ones you install later and ones that break again after an update. Repairs are written next to the original file, never on top of it, and anything already working is left alone.
|
|
77
65
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
npx @lilmgenius/win-hooks status
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Or, inside a session:
|
|
66
|
+
A healthy run is silent. To look anyway:
|
|
85
67
|
|
|
86
68
|
| Command | What it does |
|
|
87
69
|
|---|---|
|
|
88
|
-
| `/win-hooks:
|
|
89
|
-
|
|
|
90
|
-
|
|
91
|
-
## Requirements
|
|
92
|
-
|
|
93
|
-
Windows 10/11, and [Git for Windows](https://git-scm.com/download/win) — which you almost certainly already have. Node.js comes with Claude Code and Codex.
|
|
70
|
+
| `/win-hooks:patch` | Checks every plugin, shows what it found, repairs anything broken |
|
|
71
|
+
| `npx @lilmgenius/win-hooks patch` | The same, from any terminal |
|
|
94
72
|
|
|
95
73
|
## Privacy
|
|
96
74
|
|
|
97
|
-
win-hooks runs entirely on your machine and sends nothing anywhere. No telemetry, no network calls, no account.
|
|
98
|
-
|
|
99
|
-
## For the curious
|
|
100
|
-
|
|
101
|
-
win-hooks never edits a plugin's own scripts. It writes a small `_hooks/` directory next to them, containing one wrapper per broken hook plus a single `run-hook.cmd` — a file that is valid batch *and* valid shell at once, so Windows and Git Bash can each run the same entry point. The plugin's `hooks.json` is then pointed at the wrapper, with the original saved as `hooks.json.bak`.
|
|
102
|
-
|
|
103
|
-
```
|
|
104
|
-
plugin/
|
|
105
|
-
├── hooks/
|
|
106
|
-
│ ├── hooks.json → now points at the wrapper
|
|
107
|
-
│ └── hooks.json.bak → your original, untouched
|
|
108
|
-
└── _hooks/
|
|
109
|
-
├── run-hook.cmd → batch + shell polyglot entry point
|
|
110
|
-
└── check → resolves the real interpreter, then execs
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Codex works the same way, with one difference: it has a native `commandWindows` field, so win-hooks *adds* the Windows command instead of replacing the portable one. Your plugins keep working unchanged on macOS and Linux.
|
|
114
|
-
|
|
115
|
-
Wrapper filenames are deliberately extensionless (`check`, not `check.sh`) — Claude Code auto-prepends `bash` to anything containing `.sh` on Windows, which would undo the fix.
|
|
116
|
-
|
|
117
|
-
Contributors: [`AGENTS.md`](AGENTS.md) documents every failure mode win-hooks handles, with the root cause behind each one.
|
|
75
|
+
win-hooks runs entirely on your machine and sends nothing anywhere. No telemetry, no network calls, no account. Outside a plugin's own folder it writes only a short local log of its own runs, so you can confirm it ran.
|
|
118
76
|
|
|
119
77
|
## License
|
|
120
78
|
|
|
121
|
-
[MIT](LICENSE).
|
|
79
|
+
[MIT](LICENSE). How it works, and every failure mode it handles: [`AGENTS.md`](AGENTS.md).
|
package/bin/win-hooks.mjs
CHANGED
|
@@ -5,23 +5,25 @@
|
|
|
5
5
|
// win-hooks repair Claude Code and Codex plugin hooks
|
|
6
6
|
// win-hooks heal [host] repair one host (claude | codex)
|
|
7
7
|
// win-hooks status [host] report without changing anything
|
|
8
|
+
// win-hooks patch [host] report, repair what is not healthy, prove the result
|
|
8
9
|
//
|
|
9
10
|
// --changed-only skip when no plugin's hooks changed since the last run
|
|
10
11
|
// (the per-prompt guard; near-free on the hot path)
|
|
11
12
|
//
|
|
12
13
|
// Progress goes to stderr, never stdout: these hooks run under Claude Code,
|
|
13
|
-
// whose UserPromptSubmit stdout is injected into the model's context.
|
|
14
|
+
// whose UserPromptSubmit stdout is injected into the model's context. `status`
|
|
15
|
+
// and `patch` are the exception - a person asked for their output.
|
|
14
16
|
|
|
15
17
|
import { isWindows } from '../src/env.mjs';
|
|
16
18
|
import { HOSTS } from '../src/hosts.mjs';
|
|
17
19
|
import { heal, inspect } from '../src/heal.mjs';
|
|
18
20
|
|
|
19
|
-
const USAGE = 'usage: win-hooks [heal|status] [claude|codex] [--changed-only]';
|
|
21
|
+
const USAGE = 'usage: win-hooks [heal|status|patch] [claude|codex] [--changed-only]';
|
|
20
22
|
|
|
21
23
|
const args = process.argv.slice(2);
|
|
22
24
|
const flags = new Set(args.filter((a) => a.startsWith('--')));
|
|
23
25
|
const words = args.filter((a) => !a.startsWith('--'));
|
|
24
|
-
const command = ['heal', 'status'].includes(words[0]) ? words.shift() : 'heal';
|
|
26
|
+
const command = ['heal', 'status', 'patch'].includes(words[0]) ? words.shift() : 'heal';
|
|
25
27
|
const hostIds = words.length ? words : Object.keys(HOSTS);
|
|
26
28
|
|
|
27
29
|
if (hostIds.some((id) => !HOSTS[id])) {
|
|
@@ -35,8 +37,8 @@ if (!isWindows()) {
|
|
|
35
37
|
process.exit(0);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
if (command
|
|
39
|
-
console.log(hostIds.map(
|
|
40
|
+
if (command !== 'heal') {
|
|
41
|
+
console.log(hostIds.map(command === 'patch' ? patchHost : statusOf).join('\n\n'));
|
|
40
42
|
process.exit(0);
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -60,20 +62,55 @@ function summarize({ host, patched, failed, settings, issues, fixes }) {
|
|
|
60
62
|
lines.push('win-hooks: repairs are on disk - run /reload-plugins to apply them to this session.');
|
|
61
63
|
}
|
|
62
64
|
const unresolved = issues.length - fixes.length;
|
|
63
|
-
if (unresolved > 0) lines.push('win-hooks: ' + unresolved + ' issue(s) need attention - run /win-hooks:
|
|
65
|
+
if (unresolved > 0) lines.push('win-hooks: ' + unresolved + ' issue(s) need attention - run /win-hooks:patch');
|
|
64
66
|
return lines;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
// Report, repair what is not healthy, then prove the result - one verb,
|
|
70
|
+
// because nobody inspects hooks for their own sake. A healthy host leaves
|
|
71
|
+
// nothing to decide, and a broken one was always going to be repaired, so
|
|
72
|
+
// splitting the two only asks the user which one they needed.
|
|
73
|
+
function patchHost(id) {
|
|
74
|
+
const before = inspect(id);
|
|
75
|
+
if (healthy(before)) return report(before) + heartbeat(before);
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
heal(id);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
return report(before) + '\n\n repair failed - ' + e.message;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const after = inspect(id);
|
|
84
|
+
return report(before) + '\n\n' + report(after, 'after repair') + heartbeat(after)
|
|
85
|
+
+ '\n repairs are on disk - run /reload-plugins to apply them to this session.';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Every function below is a declaration, not a const: the dispatch above runs
|
|
89
|
+
// before this point in the module, and only declarations are hoisted.
|
|
90
|
+
function statusOf(id) {
|
|
91
|
+
const state = inspect(id);
|
|
92
|
+
return report(state) + heartbeat(state);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function healthy({ incompatible, issues, settings }) {
|
|
96
|
+
return !incompatible.length && !issues.length && !settings.length;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function report({ host, plugins, incompatible, issues, settings }, heading) {
|
|
100
|
+
const title = '# ' + host.label + (heading ? ' ' + heading : '')
|
|
101
|
+
+ ' - ' + plugins.length + ' hook file(s) scanned';
|
|
102
|
+
const lines = [title];
|
|
70
103
|
|
|
71
104
|
for (const i of incompatible) lines.push(' incompatible ' + i.id + ' [' + i.event + '] ' + i.command);
|
|
72
105
|
for (const i of issues) lines.push(' ' + i.type.padEnd(14) + i.plugin + ' ' + i.detail);
|
|
73
106
|
for (const s of settings) lines.push(' ' + s.type.padEnd(14) + s.path + ' ' + s.to);
|
|
74
107
|
if (lines.length === 1) lines.push(' healthy - every hook is Windows-compatible');
|
|
75
|
-
|
|
76
|
-
lines.push('', ' last runs:');
|
|
77
|
-
lines.push(...(log.length ? log.map((l) => ' ' + l) : [' (never run)']));
|
|
78
108
|
return lines.join('\n');
|
|
79
109
|
}
|
|
110
|
+
|
|
111
|
+
// The happy path is silent, so the run log is the only way to tell a healthy
|
|
112
|
+
// host apart from a hook that never dispatched at all (CASE-25).
|
|
113
|
+
function heartbeat({ log }) {
|
|
114
|
+
return '\n\n last runs:\n'
|
|
115
|
+
+ (log.length ? log.map((l) => ' ' + l) : [' (never run)']).join('\n');
|
|
116
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lilmgenius/win-hooks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"description": "
|
|
7
|
+
"description": "Windows auto-patcher for vibe coders.",
|
|
8
|
+
"longDescription": "win-hooks scans the Claude Code and Codex plugins installed on a Windows machine and repairs the hooks that cannot run there: .sh scripts cmd.exe cannot execute, bare Unix commands and interpreters that do not resolve, UTF-8 BOMs, and backslash paths. It repairs at every session start and again whenever a plugin update reverts a fix, so plugins installed later are covered too.",
|
|
8
9
|
"scripts": {
|
|
9
10
|
"test": "node test/run.mjs"
|
|
10
11
|
},
|
|
@@ -38,14 +39,5 @@
|
|
|
38
39
|
"bugs": {
|
|
39
40
|
"url": "https://github.com/LilMGenius/win-hooks/issues"
|
|
40
41
|
},
|
|
41
|
-
"keywords": [
|
|
42
|
-
"windows",
|
|
43
|
-
"hooks",
|
|
44
|
-
"claude-code",
|
|
45
|
-
"codex",
|
|
46
|
-
"compatibility",
|
|
47
|
-
"patch",
|
|
48
|
-
"cli",
|
|
49
|
-
"cross-platform"
|
|
50
|
-
]
|
|
42
|
+
"keywords": ["windows","hooks","claude-code","codex","plugin","compatibility","patch","cli","winux"]
|
|
51
43
|
}
|
package/src/verify.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Health check for already-patched plugins, with optional auto-repair.
|
|
2
2
|
//
|
|
3
3
|
// The issue types below are a closed vocabulary, shared verbatim with
|
|
4
|
-
// skills/
|
|
5
|
-
// all three.
|
|
4
|
+
// skills/patch/SKILL.md. Adding one means updating both.
|
|
6
5
|
|
|
7
6
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';
|
|
8
7
|
import { join } from 'node:path';
|