commit 3f48e3c361a6a7ce8ec04191c74632e1c76f1c0e Author: Zhongwei Li Date: Sat Nov 29 18:27:33 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..e304893 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "opinionated-python-hook", + "description": "Strict Python formatter hook", + "version": "0.1.0", + "author": { + "name": "ftnext", + "email": "zhongweili@tubi.tv" + }, + "hooks": [ + "./hooks" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3daaaaa --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# opinionated-python-hook + +Strict Python formatter hook diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 0000000..a36c76d --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,15 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "jq -r '.tool_input.file_path' | { read file_path; if echo \"$file_path\" | grep -q '\\.py$'; then \"$CLAUDE_PLUGIN_ROOT\"/hooks/python_format.sh \"$file_path\"; fi; }" + } + ] + } + ] + } +} diff --git a/hooks/python_format.sh b/hooks/python_format.sh new file mode 100755 index 0000000..cf32e45 --- /dev/null +++ b/hooks/python_format.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -u + +uvx hatch fmt "$1" 1>&2 +exit_code=$? +if [ $exit_code -eq 1 ]; then + exit 2 +else + exit $exit_code +fi diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..ce111b7 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,49 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:ftnext/claude-code:plugins/opinionated-python-hook", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "92fbae564ee47746863fc952df3c5a7bfebbf70f", + "treeHash": "41f711fa2323c953174647afdda5e381e40b2b505d4044c41263b47a3e5f8c67", + "generatedAt": "2025-11-28T10:16:55.566890Z", + "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": "opinionated-python-hook", + "description": "Strict Python formatter hook", + "version": "0.1.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "dcbbb00eb1053cd7df8d6aba3b6e380ec730235aad731b524846317b4b4de6c5" + }, + { + "path": "hooks/hooks.json", + "sha256": "14875a9fad3d3c5bb5cc34af5d60eeb1f6fedc50d818bd2c638aca67db4af2b1" + }, + { + "path": "hooks/python_format.sh", + "sha256": "047d33a0ad8c19141a20d4965ae9bf8e680a902d40123ffe9bd420e007232de8" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "70dcec3b6534e9cfb5503e68bd33dce1679864830a46dd11477c363e53aef23c" + } + ], + "dirSha256": "41f711fa2323c953174647afdda5e381e40b2b505d4044c41263b47a3e5f8c67" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file