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-bun",
|
||||||
|
"description": "Suggests using Bun instead of npm/npx 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-bun
|
||||||
|
|
||||||
|
Suggests using Bun instead of npm/npx commands in Bash tool calls
|
||||||
44
hooks/force-bun.sh
Executable file
44
hooks/force-bun.sh
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
# Bun に置き換えを推奨
|
||||||
|
if [[ $command =~ (^| )(npx|npm\ x|npm\ exec)( ) ]]; then
|
||||||
|
suggest_deny "Use 'bunx' instead of npx, npm x, or npm exec"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# npm version は許可
|
||||||
|
if [[ $command =~ npm\ version ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# その他の npm コマンドは Bun を推奨
|
||||||
|
if [[ $command =~ (^| )npm( ) ]]; then
|
||||||
|
suggest_deny "Use 'bun' instead of npm"
|
||||||
|
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-bun.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-bun",
|
||||||
|
"normalized": {
|
||||||
|
"repo": null,
|
||||||
|
"ref": "refs/tags/v20251128.0",
|
||||||
|
"commit": "0bcba060163f4e117158954ad2c58cf40207f22f",
|
||||||
|
"treeHash": "baf626b00fd6a2bd2cc23081a3802d307ac2af7310d3a45c00413d3da0921d22",
|
||||||
|
"generatedAt": "2025-11-28T10:19:26.416353Z",
|
||||||
|
"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-bun",
|
||||||
|
"description": "Suggests using Bun instead of npm/npx commands in Bash tool calls",
|
||||||
|
"version": "0.2.0"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"path": "README.md",
|
||||||
|
"sha256": "69a03a339b8e0c52660b06aa8f03992444acd6315247908846bd7666038281a8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "hooks/force-bun.sh",
|
||||||
|
"sha256": "93ba5ecd940d802c13913d04826abde64187e93d9649c8e9ce487c56321c8c73"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "hooks/hooks.json",
|
||||||
|
"sha256": "9fe50711d99831880f715e92da0574485a771ef08c6c4ae824ef88a571170b09"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": ".claude-plugin/plugin.json",
|
||||||
|
"sha256": "03e39ea4e9806092a2475d79ce6c1a706cec1cfd048bada431d598b367ca692b"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dirSha256": "baf626b00fd6a2bd2cc23081a3802d307ac2af7310d3a45c00413d3da0921d22"
|
||||||
|
},
|
||||||
|
"security": {
|
||||||
|
"scannedAt": null,
|
||||||
|
"scannerVersion": null,
|
||||||
|
"flags": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user