@wipcomputer/wip-branch-guard 1.9.30 → 1.9.33

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.
Files changed (2) hide show
  1. package/guard.mjs +12 -4
  2. package/package.json +1 -1
package/guard.mjs CHANGED
@@ -5,8 +5,16 @@
5
5
  // Agents must work on branches or worktrees. Never on main.
6
6
 
7
7
  import { execSync } from 'node:child_process';
8
- import { dirname } from 'node:path';
9
- import { statSync } from 'node:fs';
8
+ import { dirname, join } from 'node:path';
9
+ import { statSync, readFileSync } from 'node:fs';
10
+ import { fileURLToPath } from 'node:url';
11
+
12
+ if (process.argv.includes('--version') || process.argv.includes('-v')) {
13
+ const __dirname = dirname(fileURLToPath(import.meta.url));
14
+ const pkg = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf8'));
15
+ console.log(pkg.version);
16
+ process.exit(0);
17
+ }
10
18
 
11
19
  // Tools that modify files or git state
12
20
  const WRITE_TOOLS = new Set(['Write', 'Edit', 'NotebookEdit']);
@@ -49,8 +57,6 @@ const BLOCKED_BASH_PATTERNS = [
49
57
  /\brm\s+/,
50
58
  /\bmkdir\s+/,
51
59
  /\btouch\s+/,
52
- /\bnpm\s+link\b/,
53
- /\bnpm\s+install\s+-g\b/,
54
60
  />\s/, // redirects
55
61
  /\btee\s+/,
56
62
  /\bsed\s+-i/,
@@ -77,6 +83,8 @@ const ALLOWED_BASH_PATTERNS = [
77
83
  /--dry-run/,
78
84
  /--help/,
79
85
  /\bwip-release\b.*--dry-run/,
86
+ /\bnpm\s+install\s+-g\b/, // global installs modify /opt/homebrew/, not the repo
87
+ /\bnpm\s+link\b/, // global operation, not repo-local
80
88
  ];
81
89
 
82
90
  function deny(reason) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wipcomputer/wip-branch-guard",
3
- "version": "1.9.30",
3
+ "version": "1.9.33",
4
4
  "description": "PreToolUse hook that blocks all writes on main branch. Forces agents to work on branches or worktrees.",
5
5
  "type": "module",
6
6
  "main": "guard.mjs",