Initial commit
This commit is contained in:
11
.claude-plugin/plugin.json
Normal file
11
.claude-plugin/plugin.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "force-uv",
|
||||||
|
"description": "Suggests using UV instead of pip/pipx/venv commands in Bash tool calls",
|
||||||
|
"version": "0.2.0",
|
||||||
|
"author": {
|
||||||
|
"name": "kawaz"
|
||||||
|
},
|
||||||
|
"hooks": [
|
||||||
|
"./hooks"
|
||||||
|
]
|
||||||
|
}
|
||||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# force-uv
|
||||||
|
|
||||||
|
Suggests using UV instead of pip/pipx/venv commands in Bash tool calls
|
||||||
46
hooks/force-uv.sh
Executable file
46
hooks/force-uv.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
suggest_deny() {
|
||||||
|
local reason="$1"
|
||||||
|
jq -cn \
|
||||||
|
--arg reason "$reason" \
|
||||||
|
'{
|
||||||
|
"hookSpecificOutput": {
|
||||||
|
"hookEventName": "PreToolUse",
|
||||||
|
"permissionDecision": "deny",
|
||||||
|
"permissionDecisionReason": $reason
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# 標準入力から JSON を読み取り
|
||||||
|
input=$(</dev/stdin)
|
||||||
|
# コマンドチェックの際に複数行がある場合は最初の行のみを使用
|
||||||
|
command=$(jq -r '.tool_input.command // empty' <<< "$input")
|
||||||
|
|
||||||
|
# 引用符以降は無視する(コミットメッセージとかのコメント文字列に含む場合などの誤検知回避のため)
|
||||||
|
command=${command%%[\'\"]*}
|
||||||
|
|
||||||
|
# コマンドが空の場合は何もチェックしない
|
||||||
|
[[ -z "$command" ]] && exit 0
|
||||||
|
|
||||||
|
# UV に置き換えを推奨
|
||||||
|
if [[ $command =~ (^| )pip3?.*\ install( ) ]]; then
|
||||||
|
suggest_deny "Use 'uv add' instead of pip install"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $command =~ (^| )python.*\ -m\ venv( ) ]]; then
|
||||||
|
suggest_deny "Use 'uv init' instead of python -m venv"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $command =~ (^| )virtualenv( ) ]]; then
|
||||||
|
suggest_deny "Use 'uv venv' instead of virtualenv"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $command =~ (^| )pipx( ) ]]; then
|
||||||
|
suggest_deny "Use 'uvx' instead of pipx"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
15
hooks/hooks.json
Normal file
15
hooks/hooks.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"hooks": {
|
||||||
|
"PreToolUse": [
|
||||||
|
{
|
||||||
|
"matcher": "Bash",
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/force-uv.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
49
plugin.lock.json
Normal file
49
plugin.lock.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"$schema": "internal://schemas/plugin.lock.v1.json",
|
||||||
|
"pluginId": "gh:kawaz/claude-plugins:plugins/force-uv",
|
||||||
|
"normalized": {
|
||||||
|
"repo": null,
|
||||||
|
"ref": "refs/tags/v20251128.0",
|
||||||
|
"commit": "ef38854b4f653671612da178cbabfeb895b7a47d",
|
||||||
|
"treeHash": "3218ed2806bc3058d515654aa865167ea7b7ced26fee75255013470e93222afe",
|
||||||
|
"generatedAt": "2025-11-28T10:19:26.602980Z",
|
||||||
|
"toolVersion": "publish_plugins.py@0.2.0"
|
||||||
|
},
|
||||||
|
"origin": {
|
||||||
|
"remote": "git@github.com:zhongweili/42plugin-data.git",
|
||||||
|
"branch": "master",
|
||||||
|
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
|
||||||
|
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
|
||||||
|
},
|
||||||
|
"manifest": {
|
||||||
|
"name": "force-uv",
|
||||||
|
"description": "Suggests using UV instead of pip/pipx/venv commands in Bash tool calls",
|
||||||
|
"version": "0.2.0"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"path": "README.md",
|
||||||
|
"sha256": "50063557de005f9c0da563055806c862c52bf16e11e649a1e06fc73dfe1e9272"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "hooks/hooks.json",
|
||||||
|
"sha256": "1c62a98c2081c4a74ccb673744a0f200791a78ef8864ae977d98d198ff357b51"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "hooks/force-uv.sh",
|
||||||
|
"sha256": "6631d76f3327926c88efbc0e5d47e45723f831f93512614030bc7bbe3c234c06"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": ".claude-plugin/plugin.json",
|
||||||
|
"sha256": "a4fdb260b6ee7a60a8f75ae3a19b690aacef7c106f2e31b8655a0b8dc4f5ed85"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dirSha256": "3218ed2806bc3058d515654aa865167ea7b7ced26fee75255013470e93222afe"
|
||||||
|
},
|
||||||
|
"security": {
|
||||||
|
"scannedAt": null,
|
||||||
|
"scannerVersion": null,
|
||||||
|
"flags": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user