diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 528e2d6..c351e85 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -11,7 +11,7 @@ "name": "learn", "source": "./plugins/learn", "description": "Domain-based memory with selective saving, signal detection, and memory hygiene", - "version": "2.1.1", + "version": "2.1.2", "keywords": ["learn", "memory", "patterns", "gotchas", "domains", "cleanup", "hygiene"] } ] diff --git a/plugins/learn/.claude-plugin/plugin.json b/plugins/learn/.claude-plugin/plugin.json index 9440f6b..8088147 100644 --- a/plugins/learn/.claude-plugin/plugin.json +++ b/plugins/learn/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "learn", "description": "Claude Learn: Session analysis for patterns and gotchas with domain-based memory, selective saving, and memory hygiene", - "version": "2.1.1", + "version": "2.1.2", "author": { "name": "Romfast Team" } diff --git a/plugins/learn/commands/setup.md b/plugins/learn/commands/setup.md new file mode 100644 index 0000000..78b7c3e --- /dev/null +++ b/plugins/learn/commands/setup.md @@ -0,0 +1,58 @@ +# /learn:setup - Install Learn Plugin Hooks + +Instalează hooks-urile plugin-ului Learn în configurația Claude Code. + +## Task + +Verifică și instalează hooks-urile necesare pentru plugin-ul Learn în `~/.claude/settings.json`. + +### Hooks de instalat: + +1. **SessionEnd** - Reminder la sfârșitul sesiunii să rulezi `/learn:analyze` +2. **PreCompact** (auto) - Reminder înainte de auto-compact să salvezi lecțiile + +### Pași: + +1. Citește `~/.claude/settings.json` +2. Verifică dacă există deja secțiunea `hooks` +3. Adaugă sau actualizează hooks-urile pentru Learn plugin: + +```json +{ + "hooks": { + "SessionEnd": [ + { + "type": "command", + "command": "echo '\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n💡 Tip: Rulează /learn:analyze pentru a captura lecțiile din sesiune\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'", + "timeout": 5 + } + ], + "PreCompact": [ + { + "matcher": "auto", + "hooks": [ + { + "type": "command", + "command": "echo '\n⚠️ Context plin! Rulează /learn:analyze ACUM pentru a salva lecțiile înainte de compact!\n'", + "timeout": 5 + } + ] + } + ] + } +} +``` + +4. Salvează fișierul actualizat +5. Confirmă instalarea cu succes + +### Output: + +Afișează: +- Ce hooks au fost instalate +- Dacă erau deja instalate (skip) +- Instrucțiuni pentru a verifica cu `/hooks` + +### Notă: + +Această comandă modifică `~/.claude/settings.json`. Hooks-urile vor fi active din următoarea sesiune Claude Code. diff --git a/plugins/learn/scripts/install-hooks.sh b/plugins/learn/scripts/install-hooks.sh new file mode 100755 index 0000000..2940a02 --- /dev/null +++ b/plugins/learn/scripts/install-hooks.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# Claude Learn - Install Hooks +# Adaugă hooks-urile Learn în ~/.claude/settings.json + +SETTINGS_FILE="$HOME/.claude/settings.json" + +# Colors +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +CYAN='\033[0;36m' +RED='\033[0;31m' +NC='\033[0m' + +echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" +echo -e "${CYAN} Claude Learn - Hook Installation${NC}" +echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" + +# Check if settings file exists +if [ ! -f "$SETTINGS_FILE" ]; then + echo -e "${RED}Error: $SETTINGS_FILE not found${NC}" + exit 1 +fi + +# Backup +cp "$SETTINGS_FILE" "$SETTINGS_FILE.backup" +echo -e "${GREEN}✓${NC} Backup created: settings.json.backup" + +# Check if hooks already exist +if python3 -c "import json; d=json.load(open('$SETTINGS_FILE')); exit(0 if 'hooks' in d else 1)" 2>/dev/null; then + echo -e "${YELLOW}⚠${NC} Hooks section already exists in settings.json" + echo -e " Checking for Learn hooks..." + + # Check if SessionEnd already has our hook + HAS_LEARN=$(python3 -c " +import json +d = json.load(open('$SETTINGS_FILE')) +hooks = d.get('hooks', {}) +session_end = hooks.get('SessionEnd', []) +for h in session_end: + cmd = h.get('command', '') + if 'learn:analyze' in cmd: + print('yes') + exit(0) +print('no') +" 2>/dev/null) + + if [ "$HAS_LEARN" = "yes" ]; then + echo -e "${GREEN}✓${NC} Learn hooks already installed!" + exit 0 + fi +fi + +# Add hooks using Python +python3 << 'PYTHON_SCRIPT' +import json +import os + +settings_file = os.path.expanduser("~/.claude/settings.json") + +with open(settings_file, 'r') as f: + settings = json.load(f) + +# Define Learn hooks +learn_session_end = { + "type": "command", + "command": "echo '\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n💡 Tip: Rulează /learn:analyze pentru a captura lecțiile din sesiune\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'", + "timeout": 5 +} + +learn_pre_compact = { + "matcher": "auto", + "hooks": [ + { + "type": "command", + "command": "echo '\n⚠️ Context plin! Rulează /learn:analyze ACUM pentru a salva lecțiile înainte de compact!\n'", + "timeout": 5 + } + ] +} + +# Initialize hooks if not exists +if 'hooks' not in settings: + settings['hooks'] = {} + +# Add SessionEnd hook +if 'SessionEnd' not in settings['hooks']: + settings['hooks']['SessionEnd'] = [] +settings['hooks']['SessionEnd'].append(learn_session_end) + +# Add PreCompact hook +if 'PreCompact' not in settings['hooks']: + settings['hooks']['PreCompact'] = [] +settings['hooks']['PreCompact'].append(learn_pre_compact) + +# Write back +with open(settings_file, 'w') as f: + json.dump(settings, f, indent=2) + +print("Hooks added successfully!") +PYTHON_SCRIPT + +if [ $? -eq 0 ]; then + echo -e "${GREEN}✓${NC} SessionEnd hook installed" + echo -e "${GREEN}✓${NC} PreCompact hook installed" + echo "" + echo -e "${CYAN}Hooks-urile vor fi active din următoarea sesiune Claude Code.${NC}" + echo -e "Verifică cu: ${YELLOW}/hooks${NC}" +else + echo -e "${RED}Error installing hooks${NC}" + # Restore backup + mv "$SETTINGS_FILE.backup" "$SETTINGS_FILE" + exit 1 +fi