Add Claude Code plugin scaffold for single-repo install
Consolidates plugin components (hooks, commands, skills, MCP config) into this repo so it can be installed with: claude plugins install github:ViktorBarzin/claude-memory-mcp - .claude-plugin/plugin.json: manifest with all hook events - mcp/memory-mcp.json: MCP server config using existing src/ - hooks/: compaction survival, auto-recall, auto-learn, auto-approve - commands/: /remember and /recall slash commands - skills/: memory-management skill - Bump MCP server to v2.0.0 with metaclaw migration fallback - Update README with quick install and plugin hooks docs
This commit is contained in:
parent
66bb407bae
commit
0d1cff3038
12 changed files with 653 additions and 2 deletions
69
hooks/auto-allow-memory-tools.py
Normal file
69
hooks/auto-allow-memory-tools.py
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Auto-allow hook for claude-memory plugin tools.
|
||||
|
||||
This PermissionRequest hook automatically allows any tool whose name matches
|
||||
the claude_memory MCP server pattern to proceed without user confirmation.
|
||||
|
||||
Environment variables:
|
||||
DEBUG_CLAUDE_MEMORY_HOOKS=1 Enable debug logging to stderr
|
||||
DISABLE_CLAUDE_MEMORY_AUTO_APPROVE=1 Disable auto-approve (for debugging)
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
DEBUG = os.environ.get("DEBUG_CLAUDE_MEMORY_HOOKS", "").lower() in ("1", "true", "yes")
|
||||
DISABLED = os.environ.get("DISABLE_CLAUDE_MEMORY_AUTO_APPROVE", "").lower() in (
|
||||
"1",
|
||||
"true",
|
||||
"yes",
|
||||
)
|
||||
|
||||
# Match any tool from this plugin's MCP server, resilient to slug variations
|
||||
# e.g. mcp__plugin_claude-memory_claude_memory__memory_store
|
||||
# mcp__claude_memory__memory_recall
|
||||
TOOL_PATTERN = re.compile(r"mcp__.*claude_memory__(?:memory_|secret_)")
|
||||
|
||||
|
||||
def debug(msg: str) -> None:
|
||||
"""Print debug message to stderr if DEBUG is enabled."""
|
||||
if DEBUG:
|
||||
print(f"[claude-memory] {msg}", file=sys.stderr)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if DISABLED:
|
||||
debug("Auto-approve disabled via DISABLE_CLAUDE_MEMORY_AUTO_APPROVE")
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
input_data = json.load(sys.stdin)
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"Error: Invalid JSON input: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
tool_name = input_data.get("tool_name", "")
|
||||
debug(f"Permission request for: {tool_name}")
|
||||
|
||||
if TOOL_PATTERN.search(tool_name):
|
||||
debug(f"Auto-allowing: {tool_name}")
|
||||
output = {
|
||||
"hookSpecificOutput": {
|
||||
"hookEventName": "PermissionRequest",
|
||||
"decision": {
|
||||
"behavior": "allow",
|
||||
},
|
||||
}
|
||||
}
|
||||
json.dump(output, sys.stdout)
|
||||
else:
|
||||
debug(f"Not a claude-memory tool, passing through: {tool_name}")
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue