claude-warden 2.4.1 → 2.5.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.
@@ -8,7 +8,7 @@
8
8
  {
9
9
  "name": "warden",
10
10
  "description": "Auto-approves safe commands, blocks dangerous ones, prompts for the rest",
11
- "version": "2.4.1",
11
+ "version": "2.5.0",
12
12
  "author": {
13
13
  "name": "banyudu"
14
14
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warden",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "Smart command safety filter for Claude Code — parses shell pipelines and evaluates per-command safety rules to auto-approve safe commands and block dangerous ones",
5
5
  "author": {
6
6
  "name": "banyudu"
package/README.md CHANGED
@@ -104,27 +104,62 @@ cd claude-warden && npm install && npm run build
104
104
  claude --plugin-dir ./claude-warden
105
105
  ```
106
106
 
107
- ## Codex CLI (experimental)
107
+ ## Codex CLI
108
108
 
109
- Codex currently uses `execpolicy` (`.rules` files) for command approvals. Warden can export your effective command-level decisions to a Codex rules file:
109
+ Codex supports [PreToolUse hooks](https://developers.openai.com/codex/hooks) with a wire protocol nearly identical to Claude Code's, so the **same** Warden hook binary works natively — no rule export needed.
110
+
111
+ ### Setup
112
+
113
+ 1. Install Warden globally so the `warden-hook` binary lands in your `PATH`:
110
114
 
111
115
  ```bash
112
- pnpm run build
113
- pnpm run codex:export-rules
116
+ npm install -g claude-warden
117
+ ```
118
+
119
+ 2. Drop the following into `~/.codex/hooks.json` (user-wide) or `<repo>/.codex/hooks.json` (project-scoped):
120
+
121
+ ```json
122
+ {
123
+ "hooks": {
124
+ "PreToolUse": [
125
+ {
126
+ "matcher": "Bash",
127
+ "hooks": [
128
+ {
129
+ "type": "command",
130
+ "command": "warden-hook",
131
+ "statusMessage": "Checking Bash command with Warden"
132
+ }
133
+ ]
134
+ }
135
+ ]
136
+ }
137
+ }
114
138
  ```
115
139
 
116
- This writes `.codex/rules/warden.rules` in the current project by default.
140
+ A ready-to-use template ships at [`.codex/hooks.json`](.codex/hooks.json). If `warden-hook` isn't on your `PATH` (e.g. non-global install), use the absolute path instead: `node /path/to/claude-warden/dist/index.cjs`.
117
141
 
118
- - Use `--cwd <dir>` to choose which workspace config to load.
119
- - Use `--out <path>` to choose an output path.
120
- - Use `--stdout` to print the generated rules.
142
+ ### How it works
143
+
144
+ Codex sends the same `{tool_name, tool_input.command, cwd, session_id, ...}` payload on stdin and accepts the same `hookSpecificOutput.permissionDecision` response as Claude Code. The identical `dist/index.cjs` binary runs the full parser/evaluator pipeline — trusted hosts, YOLO mode, argument-aware rules, and all. The same `~/.claude/warden.yaml` and `.claude/warden.yaml` config files drive both.
145
+
146
+ ### Known Codex limitations
121
147
 
122
- Example:
148
+ - **Bash only** — Codex PreToolUse currently intercepts only shell commands; MCP, Write, and WebSearch tools are not hooked.
149
+ - **Work in progress upstream** — Codex's hook system may miss some shell invocations. Treat it as defense-in-depth, not a hard sandbox.
150
+ - **`deny` is authoritative; `allow`/`ask` fail open** — Codex currently honors `deny` (and exit code 2) but treats `allow`/`ask` as "fail open" (command proceeds). This is safe: Warden's deny list still blocks dangerous commands.
151
+ - **No undo** — hooks cannot revert a command that has already executed.
152
+
153
+ ### Fallback: static rule export
154
+
155
+ For environments where the hook approach isn't viable, Warden can still export a static `execpolicy` rules file:
123
156
 
124
157
  ```bash
125
- node dist/codex-export.cjs --cwd . --out .codex/rules/warden.rules
158
+ pnpm run codex:export-rules # writes .codex/rules/warden.rules
126
159
  ```
127
160
 
161
+ Use `--cwd <dir>`, `--out <path>`, or `--stdout` to customize. This snapshot loses dynamic behavior (trusted hosts, YOLO, etc.) but works with older Codex setups.
162
+
128
163
  ## GitHub Copilot CLI
129
164
 
130
165
  Warden supports GitHub Copilot CLI's [preToolUse hook](https://docs.github.com/en/copilot/reference/hooks-configuration) natively.
package/dist/cli.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
package/dist/copilot.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "claude-warden",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "Smart command safety filter for Claude Code — auto-approves safe commands, blocks dangerous ones",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "bin": {
8
- "warden": "dist/cli.cjs"
8
+ "warden": "dist/cli.cjs",
9
+ "warden-hook": "dist/index.cjs"
9
10
  },
10
11
  "license": "MIT",
11
12
  "author": "banyudu",
@@ -34,16 +35,6 @@
34
35
  "README.md",
35
36
  "LICENSE"
36
37
  ],
37
- "dependencies": {
38
- "bash-parser": "npm:@banyudu/bash-parser@0.5.2",
39
- "yaml": "^2.4.0"
40
- },
41
- "devDependencies": {
42
- "@types/node": "^20.0.0",
43
- "tsup": "^8.0.0",
44
- "typescript": "^5.4.0",
45
- "vitest": "^1.6.0"
46
- },
47
38
  "scripts": {
48
39
  "build": "tsup",
49
40
  "dev": "tsup --watch",
@@ -57,7 +48,19 @@
57
48
  "release": "scripts/release.sh patch",
58
49
  "release:minor": "scripts/release.sh minor",
59
50
  "release:major": "scripts/release.sh major",
51
+ "prepublishOnly": "pnpm run sync-plugin-version && pnpm run build && pnpm run test",
52
+ "postpublish": "claude plugin update claude-warden@local 2>/dev/null; claude plugin update warden@claude-warden 2>/dev/null; echo 'Plugin caches updated'",
60
53
  "docs:dev": "cd docs-src && pnpm dev",
61
54
  "docs:build": "cd docs-src && pnpm install && pnpm build"
55
+ },
56
+ "dependencies": {
57
+ "bash-parser": "npm:@banyudu/bash-parser@0.5.2",
58
+ "yaml": "^2.4.0"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^20.0.0",
62
+ "tsup": "^8.0.0",
63
+ "typescript": "^5.4.0",
64
+ "vitest": "^1.6.0"
62
65
  }
63
- }
66
+ }