Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ These run **when a session begins**:

These run **before** a tool call is executed:

- `mcp__very-good-cli__.*` matcher → `check-vgv-cli.sh` — validates that the Very Good CLI is installed and at version >= 1.3.0; exits 2 on failure (blocking)
- `mcp__.*very-good-cli__.*` matcher → `check-vgv-cli.sh` — auto-approves the Very Good CLI MCP tool call by returning a PreToolUse `allow` decision, so it is always permitted regardless of run mode (interactive, headless, or `skipAutoPermissionPrompt`) and never dead-ends when the tool isn't on `permissions.allow`; denies with an install/upgrade message if the CLI is missing or < 1.3.0. The `.*` in the matcher covers both the bare `mcp__very-good-cli__*` server (repo-root `.mcp.json`) and the plugin-namespaced `mcp__plugin_<plugin>_very-good-cli__*` form used when installed from a marketplace
- `Bash` matcher → `block-cli-workarounds.sh` — prevents direct CLI bypass of VGV CLI commands through the Bash tool; exits 2 on failure (blocking)

Both PreToolUse scripts share common utilities from `vgv-cli-common.sh`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This plugin includes SessionStart, PreToolUse, and PostToolUse hooks that valida
| Hook | Trigger | Behavior |
| ---- | ------- | -------- |
| **Warn Missing MCP** (`warn-missing-mcp.sh`) | SessionStart | Warns if the Very Good CLI is missing or older than 1.3.0; non-blocking |
| **Check VGV CLI** (`check-vgv-cli.sh`) | PreToolUse (`mcp__very-good-cli__.*`) | Validates the Very Good CLI is installed and ≥ 1.3.0; exits 2 on failure (blocking) |
| **Check VGV CLI** (`check-vgv-cli.sh`) | PreToolUse (`mcp__.*very-good-cli__.*`) | Auto-approves Very Good CLI MCP tool calls in every run mode via a PreToolUse `allow` decision, so they never dead-end when the tool isn't on `permissions.allow` (including under `skipAutoPermissionPrompt`); denies with an install/upgrade message if the CLI is missing or < 1.3.0 |
| **Block CLI Workarounds** (`block-cli-workarounds.sh`) | PreToolUse (`Bash`) | Blocks direct CLI bypass of Very Good CLI commands through the Bash tool; exits 2 on failure (blocking) |
| **Analyze** (`analyze.sh`) | PostToolUse (`Edit`/`Write`) | Runs `dart analyze` on the modified `.dart` file; exits 2 on failure (blocking — Claude must fix issues before continuing) |
| **Format** (`format.sh`) | PostToolUse (`Edit`/`Write`) | Runs `dart format` on the modified `.dart` file; always exits 0 (non-blocking — formatting is applied silently) |
Expand Down
2 changes: 1 addition & 1 deletion hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"PreToolUse": [
{
"matcher": "mcp__very-good-cli__.*",
"matcher": "mcp__.*very-good-cli__.*",
"hooks": [
{
"type": "command",
Expand Down
12 changes: 8 additions & 4 deletions hooks/scripts/check-vgv-cli.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
# PreToolUse hook: verify very_good_cli is installed before
# allowing Very Good CLI MCP tool calls.
# PreToolUse hook: gate Very Good CLI MCP tool calls.
# When the CLI is installed and new enough, auto-approve the call so it is
# always allowed regardless of run mode; otherwise deny with an install/
# upgrade message instead of letting the call fail silently.

if ! command -v jq &>/dev/null; then
echo "jq is required for check-vgv-cli hook but not found" >&2
Expand All @@ -21,5 +23,7 @@ case "$cli_status" in
;;
esac

# Version OK
exit 0
# Version OK — auto-approve so the Very Good CLI MCP tool is always allowed,
# even under skipAutoPermissionPrompt where a non-allowlisted tool would
# otherwise fail closed and silently.
allow "Very Good CLI >= ${MIN_VERSION} verified; auto-approving Very Good CLI MCP tool call."
17 changes: 17 additions & 0 deletions hooks/scripts/vgv-cli-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ deny() {
exit 0
}

# Auto-approve the tool call, skipping the interactive permission prompt.
# A PreToolUse "allow" fires before the permission-mode check, so the call
# proceeds in every run mode (interactive, headless, skipAutoPermissionPrompt).
# Explicit deny/ask rules and managed deny lists still take precedence.
allow() {
jq -n \
--arg reason "$1" \
'{
hookSpecificOutput: {
hookEventName: "PreToolUse",
permissionDecision: "allow",
permissionDecisionReason: $reason
}
}'
exit 0
}

# Check Very Good CLI availability and version.
# Returns: "ok", "not_installed", or "outdated:<version>"
check_vgv_cli() {
Expand Down