@oked/claude-code 0.6.23 → 0.6.25
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 +17 -1
- package/dist/cli.js +87 -38
- package/dist/hook-config.d.ts +14 -2
- package/dist/hook-config.js +33 -3
- package/dist/hook.js +9 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -18,6 +18,10 @@ oked init
|
|
|
18
18
|
|
|
19
19
|
`oked init` writes a `PreToolUse` hook into the current project's `.claude/settings.json`, opens the device-pairing page in your browser, and stores the API key in `~/.oked/config.json`. Open a new Claude Code session in that project.
|
|
20
20
|
|
|
21
|
+
You can also install OKed as a Claude Code plugin, with no global npm install. In Claude Code run `/plugin marketplace add oked-ai/oked-sdk`, then `/plugin install oked@oked`, then `/oked:pair`. The plugin ships the hook as one file and reads the API key from the plugin configuration (`CLAUDE_PLUGIN_OPTION_APIKEY`). Until you pair, a risky action returns `ask`. See [plugins/claude-code](../../plugins/claude-code).
|
|
22
|
+
|
|
23
|
+
If the plugin is enabled, `oked init` does not add a settings hook. If both are already installed, the plugin gates and the settings hook stands down, so the action is asked once. `oked uninstall` removes the project settings entry. Turning the plugin off makes that entry gate again.
|
|
24
|
+
|
|
21
25
|
On a TTY, unless `NO_COLOR` is set, init also prints a QR code of the pairing link. The QR opens that link in the phone's browser.
|
|
22
26
|
|
|
23
27
|
The approval window is 10 minutes. The hook process is allowed 690 seconds, and the SDK client waits 630 seconds, so a timeout becomes a deny instead of Claude killing the hook first.
|
|
@@ -43,10 +47,22 @@ The hook uses a four-tier classifier. Classification is effect-based: it detects
|
|
|
43
47
|
| `safe` | Allow, no notification | Reads and queries, a DB `SELECT`, and any Bash command with no detected side effect: `ls`, `grep`, `jq`, plain `curl` GET. Test runners and script files are included only when the Bash sandbox is containing child processes (see below). |
|
|
44
48
|
| `warning` | Terminal log only, no approval | A reversible local change (file create, `cp`, `mv`, a `/tmp` delete, local git `add`/`commit`, `npm install`, SQL `INSERT` or `CREATE`), plus a plain `git push` |
|
|
45
49
|
| `review` | Wait for approval | Sensitive-path writes (`~/.ssh`, shell rc, system dirs, OKed config), `sudo`, outward message or email sends, `curl` POST/PUT/PATCH with an inline body, other cloud CLI writes (`aws s3 cp` to a bucket, `kubectl apply`, `helm upgrade`, a preview deploy), MCP tools named `create_*`, `send_*`, or `update_*` |
|
|
46
|
-
| `high_stakes` | Wait for approval, with confirmation | Destructive or hard to undo: `rm` of non-temp data, `DROP TABLE` or `DELETE FROM`, a force push (`git push --force`, `-f`, or `--force-with-lease`), a remote branch delete (`git push --delete`, `-d`, or `git push origin :branch`), `reset --hard`, `branch -D`, `mkfs`, `dd` to a device, `shutdown`, `curl` DELETE, file upload, pay or send APIs, `ssh` / `scp`, `npm publish`, `kill`, cloud and cluster deletes (`aws s3 rm`, `kubectl delete`), `terraform apply` / `destroy`, production deploys (`vercel --prod`, `fly deploy`), Stripe CLI writes |
|
|
50
|
+
| `high_stakes` | Wait for approval, with confirmation | Destructive or hard to undo: `rm` of non-temp data, PowerShell `Remove-Item -Recurse` (and `ri` / `del` / `rmdir` / `rd` with `-r`), `rmdir /s`, `rd /s`, `del /s`, `Format-Volume`, `format X:`, a drive root or home directory (`C:\`, `D:\`, `/`, `~`, `$HOME`, `%USERPROFILE%`), `find -delete` and `git clean -fdx` outside a temp or build directory, `DROP TABLE` or `DELETE FROM`, a force push (`git push --force`, `-f`, or `--force-with-lease`), a remote branch delete (`git push --delete`, `-d`, or `git push origin :branch`), `reset --hard`, `branch -D`, `mkfs`, `dd` to a device, `shutdown`, `curl` DELETE, a GraphQL `volumeDelete`, file upload, pay or send APIs, `ssh` / `scp`, `npm publish`, `kill`, cloud and cluster deletes (`aws s3 rm`, `kubectl delete`), `terraform apply` / `destroy`, production deploys (`vercel --prod`, `fly deploy`), Stripe CLI writes |
|
|
47
51
|
|
|
48
52
|
A Bash command that matches none of those effect categories defaults to `safe`. Cloud CLI reads (`aws s3 ls`, `kubectl get`, `terraform plan`), `--help`, and dry runs are `safe`. Running a command is not, by itself, a reason to interrupt you. Unknown tools that are not Bash default to `review`. MCP tools named `delete_*`, `drop_*`, or `remove_*` are `high_stakes`.
|
|
49
53
|
|
|
54
|
+
`bash -c`, `sh -c`, `powershell -Command`, `pwsh -c`, and `cmd /c` are classified by the command inside them. A broken `\"` on a recursive delete asks even when the text names `node_modules`, a build directory, or a temp folder. That quoting is how a cleanup became a drive-root delete on Windows.
|
|
55
|
+
|
|
56
|
+
Deleting only a temp directory (`/tmp/foo`, `$env:TEMP\foo`, `%TEMP%\foo`) or a build output directory (`build`, `dist`, `.next`) stays `warning`. `rmdir` of an empty folder stays `warning`. `git clean -n` and `Format-Volume -WhatIf` stay `safe`.
|
|
57
|
+
|
|
58
|
+
### Subagents, PowerShell, and commands the hook cannot see
|
|
59
|
+
|
|
60
|
+
Claude Code runs `PreToolUse` hooks from settings, managed settings, and plugins inside a subagent. Each of that subagent's tool calls fires the same hook, and the input includes `agent_id` and `agent_type`. Current Claude Code names the subagent tool `Agent`. Older sessions and Cursor send `Task`. `oked init` matches both. Starting the subagent is `safe`. The Bash, PowerShell, Write, and Edit calls it makes are classified on their own. A subagent transcript does not record hook results, so an empty-looking transcript is not proof the hook was skipped.
|
|
61
|
+
|
|
62
|
+
On Windows without Git Bash, Claude Code does not register the Bash tool. Shell commands go through the PowerShell tool, with the same `command` field. The settings hook and the plugin hook (`plugins/claude-code/hooks/hooks.json`) both match `PowerShell` and `Task`. An older matcher that only lists `Bash` never runs there. `oked init` adds `PowerShell` next to `Bash`, and `Task` next to `Agent`.
|
|
63
|
+
|
|
64
|
+
OKed only sees the tool call. It does not see a command that runs inside another process. In [anthropics/claude-code#105342](https://github.com/anthropics/claude-code/issues/105342) a subagent's `cargo test` ran `rm -rf ~`. The hook saw `cargo test`, not the `rm`. When the Bash sandbox is not containing child processes, that runner asks (`review`). When the sandbox is on, the runner stays `safe`, and the inner `rm` is still invisible. The same limit applies to a script file (`powershell -File wipe.ps1`, `./wipe.ps1`, `cmd /c wipe.bat`): the file body is not read. An inline `-Command` or `-c` body is read, because it is part of the tool call.
|
|
65
|
+
|
|
50
66
|
### Test runners and scripts
|
|
51
67
|
|
|
52
68
|
`cargo test`, `npm test`, `npm run <script>`, `pnpm` / `yarn` test and scripts, `pytest`, `go test`, `make <target>`, `./script.sh`, `bash script.sh`, `node scripts/x.mjs`, and `npx <tool>` run code the hook never sees. A child process can delete files without a second tool call. When the Bash sandbox is not containing those processes, OKed asks (`review`) before the runner. `ls`, `git status`, `git commit`, and `npm install` are unchanged. `node -e` and `python -c` stay `safe`, because the body is in the command string.
|
package/dist/cli.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { OKedClient, OKED_CONFIG_PATH } from "@oked/sdk";
|
|
5
|
-
import { claudeSandboxEnforced, maskKey, OKED_RECEIPTS_LOG, pairDevice, SANDBOX_INIT_HINT, verifyReceiptsFile, writeOkedConfig, } from "@oked/hook-core";
|
|
6
|
-
import { HOOK_CONFIG, hasOkedCommandHook,
|
|
5
|
+
import { claudeSandboxEnforced, findClaudeOkedHooks, maskKey, OKED_RECEIPTS_LOG, okedPluginBundleOnDisk, okedPluginIsEnabled, pairDevice, SANDBOX_INIT_HINT, verifyReceiptsFile, writeOkedConfig, } from "@oked/hook-core";
|
|
6
|
+
import { HOOK_CONFIG, hasOkedCommandHook, ensureShellMatcher, ensureHookTimeout, upgradeOkedHooks, upgradeSettingsFile, userSettingsPath, } from "./hook-config.js";
|
|
7
7
|
import { CLIENT_VERSION } from "./version.js";
|
|
8
8
|
const DEFAULT_BACKEND_URL = process.env.OKED_BACKEND_URL || "https://api.oked.ai";
|
|
9
9
|
/** `oked init --key-only`: create or show the API key; add or change no hook. */
|
|
@@ -68,48 +68,86 @@ async function initKeyOnly() {
|
|
|
68
68
|
console.log(` Paired ✓ API key ${maskKey(apiKey)} saved to ${OKED_CONFIG_PATH}`);
|
|
69
69
|
console.log(" No Claude Code hook was added. Run `oked init` without --key-only to add it.");
|
|
70
70
|
}
|
|
71
|
+
function projectHasOkedHook(settings) {
|
|
72
|
+
const hooks = (settings.hooks || {});
|
|
73
|
+
const preToolUse = (hooks.PreToolUse || []);
|
|
74
|
+
return preToolUse.some(hasOkedCommandHook);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The plugin and `oked-hook` must not both ask. When the plugin is enabled,
|
|
78
|
+
* leave any existing settings hook in place (it stands down while the plugin
|
|
79
|
+
* hook file is on disk) and do not add another one.
|
|
80
|
+
*/
|
|
81
|
+
function reportPluginInsteadOfHook(settings) {
|
|
82
|
+
console.log("OKed Claude Code plugin is enabled. Not adding a settings hook.");
|
|
83
|
+
console.log(" The plugin gates tool calls. A second hook would ask twice.");
|
|
84
|
+
if (!okedPluginBundleOnDisk()) {
|
|
85
|
+
console.log(" The plugin hook file was not found on disk yet. If tool calls are not gated, reinstall the plugin.");
|
|
86
|
+
}
|
|
87
|
+
const hasSettingsHook = projectHasOkedHook(settings) || findClaudeOkedHooks(process.cwd()).length > 0;
|
|
88
|
+
if (hasSettingsHook) {
|
|
89
|
+
console.log(" An oked-hook entry is still installed. It stands down while the plugin hook file is on disk.");
|
|
90
|
+
console.log(" Run `oked uninstall` to remove the project entry. If you disable the plugin, that entry gates again.");
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
console.log(" Pair inside Claude Code with /oked:pair, then save the API key in the plugin configuration.");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
71
96
|
async function init() {
|
|
72
97
|
if (KEY_ONLY)
|
|
73
98
|
return initKeyOnly();
|
|
74
99
|
const settingsPath = getSettingsPath();
|
|
75
100
|
const settings = readSettings(settingsPath);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return false;
|
|
86
|
-
const nextMatcher = ensureMcpMatcher(entry.matcher);
|
|
87
|
-
if (nextMatcher !== entry.matcher) {
|
|
88
|
-
entry.matcher = nextMatcher;
|
|
89
|
-
updatedOkedHook = true;
|
|
101
|
+
const pluginOn = okedPluginIsEnabled(process.cwd());
|
|
102
|
+
if (pluginOn) {
|
|
103
|
+
reportPluginInsteadOfHook(settings);
|
|
104
|
+
if (upgradeOkedHooks(settings)) {
|
|
105
|
+
const hooks = (settings.hooks || {});
|
|
106
|
+
settings.hooks = hooks;
|
|
107
|
+
writeSettings(settingsPath, settings);
|
|
108
|
+
console.log("OKed hook updated.");
|
|
109
|
+
console.log(` Config: ${settingsPath}`);
|
|
90
110
|
}
|
|
91
|
-
if (ensureHookTimeout(entry))
|
|
92
|
-
updatedOkedHook = true;
|
|
93
|
-
return true;
|
|
94
|
-
});
|
|
95
|
-
if (!hasOked) {
|
|
96
|
-
preToolUse.push(HOOK_CONFIG);
|
|
97
|
-
hooks.PreToolUse = preToolUse;
|
|
98
|
-
settings.hooks = hooks;
|
|
99
|
-
writeSettings(settingsPath, settings);
|
|
100
|
-
console.log("OKed hook installed.");
|
|
101
|
-
console.log(` Config: ${settingsPath}`);
|
|
102
|
-
}
|
|
103
|
-
else if (updatedOkedHook) {
|
|
104
|
-
hooks.PreToolUse = preToolUse;
|
|
105
|
-
settings.hooks = hooks;
|
|
106
|
-
writeSettings(settingsPath, settings);
|
|
107
|
-
console.log("OKed hook updated.");
|
|
108
|
-
console.log(` Config: ${settingsPath}`);
|
|
109
111
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
// Merge OKed hook into existing hooks. Skipped when the plugin is the gate.
|
|
113
|
+
if (!pluginOn) {
|
|
114
|
+
const hooks = (settings.hooks || {});
|
|
115
|
+
const preToolUse = (hooks.PreToolUse || []);
|
|
116
|
+
// Check if OKed hook already exists and upgrade it in place: older matchers
|
|
117
|
+
// need to cover MCP tools (`mcp__<server>__<tool>`) as regular PreToolUse
|
|
118
|
+
// events, and older timeouts predate the 10-minute approval window.
|
|
119
|
+
let updatedOkedHook = false;
|
|
120
|
+
const hasOked = preToolUse.some((entry) => {
|
|
121
|
+
if (!hasOkedCommandHook(entry))
|
|
122
|
+
return false;
|
|
123
|
+
const nextMatcher = ensureShellMatcher(entry.matcher);
|
|
124
|
+
if (nextMatcher !== entry.matcher) {
|
|
125
|
+
entry.matcher = nextMatcher;
|
|
126
|
+
updatedOkedHook = true;
|
|
127
|
+
}
|
|
128
|
+
if (ensureHookTimeout(entry))
|
|
129
|
+
updatedOkedHook = true;
|
|
130
|
+
return true;
|
|
131
|
+
});
|
|
132
|
+
if (!hasOked) {
|
|
133
|
+
preToolUse.push(HOOK_CONFIG);
|
|
134
|
+
hooks.PreToolUse = preToolUse;
|
|
135
|
+
settings.hooks = hooks;
|
|
136
|
+
writeSettings(settingsPath, settings);
|
|
137
|
+
console.log("OKed hook installed.");
|
|
138
|
+
console.log(` Config: ${settingsPath}`);
|
|
139
|
+
}
|
|
140
|
+
else if (updatedOkedHook) {
|
|
141
|
+
hooks.PreToolUse = preToolUse;
|
|
142
|
+
settings.hooks = hooks;
|
|
143
|
+
writeSettings(settingsPath, settings);
|
|
144
|
+
console.log("OKed hook updated.");
|
|
145
|
+
console.log(` Config: ${settingsPath}`);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
console.log("OKed hook already configured.");
|
|
149
|
+
console.log(` Config: ${settingsPath}`);
|
|
150
|
+
}
|
|
113
151
|
}
|
|
114
152
|
// An oked-hook entry in the user-level settings (all projects) gets the
|
|
115
153
|
// same upgrades, so existing users get a new timeout when they run init
|
|
@@ -134,6 +172,9 @@ async function init() {
|
|
|
134
172
|
console.log(` Backend: ${existingClient.backendUrl} (${ok ? "connected" : "not reachable"})`);
|
|
135
173
|
console.log("");
|
|
136
174
|
console.log("Every Claude Code session in this project is now protected.");
|
|
175
|
+
if (pluginOn) {
|
|
176
|
+
console.log("The Claude Code plugin is the gate. Set its API key with /oked:pair if you have not.");
|
|
177
|
+
}
|
|
137
178
|
printSandboxHint();
|
|
138
179
|
return;
|
|
139
180
|
}
|
|
@@ -153,7 +194,12 @@ async function init() {
|
|
|
153
194
|
console.log(` Paired ✓ Key saved to ${OKED_CONFIG_PATH}`);
|
|
154
195
|
console.log("");
|
|
155
196
|
console.log("Every Claude Code session in this project is now protected.");
|
|
156
|
-
|
|
197
|
+
if (pluginOn) {
|
|
198
|
+
console.log("The Claude Code plugin is the gate. Set its API key with /oked:pair if you have not.");
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
console.log("Open a new Claude Code session to activate the hook.");
|
|
202
|
+
}
|
|
157
203
|
printSandboxHint();
|
|
158
204
|
}
|
|
159
205
|
async function status() {
|
|
@@ -163,8 +209,10 @@ async function status() {
|
|
|
163
209
|
const preToolUse = (hooks.PreToolUse || []);
|
|
164
210
|
const hasOked = preToolUse.some(hasOkedCommandHook);
|
|
165
211
|
const client = new OKedClient();
|
|
212
|
+
const pluginOn = okedPluginIsEnabled(process.cwd());
|
|
166
213
|
console.log(`OKed status:`);
|
|
167
214
|
console.log(` Hook: ${hasOked ? "installed" : "not installed"}`);
|
|
215
|
+
console.log(` Plugin: ${pluginOn ? "enabled" : "not enabled"}`);
|
|
168
216
|
console.log(` Project config: ${existsSync(settingsPath) ? settingsPath : "not found"}`);
|
|
169
217
|
console.log(` API key: ${client.apiKey ? client.apiKey.slice(0, 8) + "..." : "not paired"}`);
|
|
170
218
|
console.log(` User config: ${existsSync(OKED_CONFIG_PATH) ? OKED_CONFIG_PATH : "not found"}`);
|
|
@@ -239,6 +287,7 @@ switch (command) {
|
|
|
239
287
|
console.log("");
|
|
240
288
|
console.log("Commands:");
|
|
241
289
|
console.log(" init Install OKed hooks in current project and pair this device");
|
|
290
|
+
console.log(" If the OKed Claude Code plugin is enabled, init does not add a hook.");
|
|
242
291
|
console.log(" --key-only Only create or show the API key. Add no hook.");
|
|
243
292
|
console.log(" --no-browser Print the pairing link. Open no browser, use no clipboard.");
|
|
244
293
|
console.log(" status Show current config and connection status");
|
package/dist/hook-config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HOOK_TIMEOUT_SECONDS } from "@oked/hook-core";
|
|
2
2
|
export declare const MCP_TOOL_MATCHER = "mcp__.*";
|
|
3
|
-
export declare const DEFAULT_TOOL_MATCHER = "Bash|Write|Edit|Agent|mcp__.*";
|
|
3
|
+
export declare const DEFAULT_TOOL_MATCHER = "Bash|PowerShell|Write|Edit|Agent|Task|mcp__.*";
|
|
4
4
|
/**
|
|
5
5
|
* Seconds Claude Code lets `oked-hook` run before killing it.
|
|
6
6
|
*
|
|
@@ -29,6 +29,18 @@ export declare function hasOkedCommandHook(entry: {
|
|
|
29
29
|
hooks?: unknown[];
|
|
30
30
|
}): boolean;
|
|
31
31
|
export declare function ensureMcpMatcher(matcher?: string): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Add shell tools an older matcher missed.
|
|
34
|
+
*
|
|
35
|
+
* `PowerShell` is Claude Code's shell on Windows when Git Bash is absent.
|
|
36
|
+
* A matcher that only lists `Bash` never fires there, so a `Remove-Item` or
|
|
37
|
+
* `rmdir /s` never reaches the classifier. `Task` is the older name of the
|
|
38
|
+
* subagent tool (current Claude Code sends `Agent`).
|
|
39
|
+
*
|
|
40
|
+
* A `*` matcher already covers both. A matcher that is not the shell/agent
|
|
41
|
+
* hook (no `Bash` and no `Agent`) is left alone.
|
|
42
|
+
*/
|
|
43
|
+
export declare function ensureShellMatcher(matcher?: string): string | undefined;
|
|
32
44
|
/**
|
|
33
45
|
* Raise a stale hook timeout in place. Installs created before the 10-minute
|
|
34
46
|
* approval window carry the old 300s, and `init()` never rewrites an entry it
|
|
@@ -42,7 +54,7 @@ export declare function ensureHookTimeout(entry: {
|
|
|
42
54
|
hooks?: unknown[];
|
|
43
55
|
}): boolean;
|
|
44
56
|
/**
|
|
45
|
-
* Apply the in-place upgrades (MCP matcher, timeout) to every `oked-hook`
|
|
57
|
+
* Apply the in-place upgrades (shell matcher, MCP matcher, timeout) to every `oked-hook`
|
|
46
58
|
* entry of a settings object. Never adds a hook. Returns true when something
|
|
47
59
|
* changed.
|
|
48
60
|
*/
|
package/dist/hook-config.js
CHANGED
|
@@ -11,7 +11,7 @@ import { homedir } from "os";
|
|
|
11
11
|
import { join } from "path";
|
|
12
12
|
import { HOOK_TIMEOUT_SECONDS } from "@oked/hook-core";
|
|
13
13
|
export const MCP_TOOL_MATCHER = "mcp__.*";
|
|
14
|
-
export const DEFAULT_TOOL_MATCHER = `Bash|Write|Edit|Agent|${MCP_TOOL_MATCHER}`;
|
|
14
|
+
export const DEFAULT_TOOL_MATCHER = `Bash|PowerShell|Write|Edit|Agent|Task|${MCP_TOOL_MATCHER}`;
|
|
15
15
|
/**
|
|
16
16
|
* Seconds Claude Code lets `oked-hook` run before killing it.
|
|
17
17
|
*
|
|
@@ -54,6 +54,36 @@ export function ensureMcpMatcher(matcher) {
|
|
|
54
54
|
}
|
|
55
55
|
return `${matcher}|${MCP_TOOL_MATCHER}`;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Add shell tools an older matcher missed.
|
|
59
|
+
*
|
|
60
|
+
* `PowerShell` is Claude Code's shell on Windows when Git Bash is absent.
|
|
61
|
+
* A matcher that only lists `Bash` never fires there, so a `Remove-Item` or
|
|
62
|
+
* `rmdir /s` never reaches the classifier. `Task` is the older name of the
|
|
63
|
+
* subagent tool (current Claude Code sends `Agent`).
|
|
64
|
+
*
|
|
65
|
+
* A `*` matcher already covers both. A matcher that is not the shell/agent
|
|
66
|
+
* hook (no `Bash` and no `Agent`) is left alone.
|
|
67
|
+
*/
|
|
68
|
+
export function ensureShellMatcher(matcher) {
|
|
69
|
+
if (!matcher)
|
|
70
|
+
return matcher;
|
|
71
|
+
// `*` already matches PowerShell, Task, and MCP tools.
|
|
72
|
+
if (matcher.split("|").map((part) => part.trim()).includes("*"))
|
|
73
|
+
return matcher;
|
|
74
|
+
const withMcp = ensureMcpMatcher(matcher);
|
|
75
|
+
if (!withMcp)
|
|
76
|
+
return withMcp;
|
|
77
|
+
const parts = withMcp.split("|").map((part) => part.trim()).filter(Boolean);
|
|
78
|
+
if (parts.includes("Bash") && !parts.includes("PowerShell")) {
|
|
79
|
+
parts.splice(parts.indexOf("Bash") + 1, 0, "PowerShell");
|
|
80
|
+
}
|
|
81
|
+
if (parts.includes("Agent") && !parts.includes("Task")) {
|
|
82
|
+
parts.splice(parts.indexOf("Agent") + 1, 0, "Task");
|
|
83
|
+
}
|
|
84
|
+
const next = parts.join("|");
|
|
85
|
+
return next === withMcp ? withMcp : next;
|
|
86
|
+
}
|
|
57
87
|
/**
|
|
58
88
|
* Raise a stale hook timeout in place. Installs created before the 10-minute
|
|
59
89
|
* approval window carry the old 300s, and `init()` never rewrites an entry it
|
|
@@ -77,7 +107,7 @@ export function ensureHookTimeout(entry) {
|
|
|
77
107
|
return updated;
|
|
78
108
|
}
|
|
79
109
|
/**
|
|
80
|
-
* Apply the in-place upgrades (MCP matcher, timeout) to every `oked-hook`
|
|
110
|
+
* Apply the in-place upgrades (shell matcher, MCP matcher, timeout) to every `oked-hook`
|
|
81
111
|
* entry of a settings object. Never adds a hook. Returns true when something
|
|
82
112
|
* changed.
|
|
83
113
|
*/
|
|
@@ -89,7 +119,7 @@ export function upgradeOkedHooks(settings) {
|
|
|
89
119
|
for (const entry of preToolUse) {
|
|
90
120
|
if (!entry || typeof entry !== "object" || !hasOkedCommandHook(entry))
|
|
91
121
|
continue;
|
|
92
|
-
const nextMatcher =
|
|
122
|
+
const nextMatcher = ensureShellMatcher(entry.matcher);
|
|
93
123
|
if (nextMatcher !== entry.matcher) {
|
|
94
124
|
entry.matcher = nextMatcher;
|
|
95
125
|
updated = true;
|
package/dist/hook.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { decide, errorInfo, logDecision } from "@oked/hook-core";
|
|
2
|
+
import { decide, errorInfo, logDecision, settingsHookYieldsToPlugin } from "@oked/hook-core";
|
|
3
3
|
import { CLIENT_ID } from "./version.js";
|
|
4
4
|
function makeOutput(decision, reason) {
|
|
5
5
|
return {
|
|
@@ -29,6 +29,14 @@ async function main() {
|
|
|
29
29
|
process.stdout.write(JSON.stringify(makeOutput("allow")));
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
+
// The Claude Code plugin gates this call when it is enabled and its hook
|
|
33
|
+
// file is installed. Returning allow here does not approve the action:
|
|
34
|
+
// the plugin's decision wins, and ask or deny from the plugin still applies.
|
|
35
|
+
if (settingsHookYieldsToPlugin(input.cwd || process.cwd())) {
|
|
36
|
+
process.stderr.write("[OKed] Claude Code plugin is enabled. This settings hook is not gating, so the action is asked once.\n");
|
|
37
|
+
process.stdout.write(JSON.stringify(makeOutput("allow")));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
32
40
|
const decision = await decide({
|
|
33
41
|
toolName: input.tool_name,
|
|
34
42
|
// Pass tool_input through. Replacing a missing value with {} makes Bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oked/claude-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.25",
|
|
4
4
|
"description": "OKed for Claude Code - zero-code human approval for sensitive actions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@oked/hook-core": "0.6.
|
|
48
|
-
"@oked/sdk": "0.6.
|
|
47
|
+
"@oked/hook-core": "0.6.25",
|
|
48
|
+
"@oked/sdk": "0.6.25"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"typescript": "^7.0.2"
|