claude-os/templates/skills/remember-this/save-to-mcp.sh

66 lines
1.3 KiB
Bash
Raw Normal View History

CRITICAL FIXES: Consolidate templates + API improvements This commit fixes several critical issues found during comprehensive review: ## CRITICAL FIX: Template Consolidation ⚠️ - Moved 6 commands from ~/.claude/commands/ to templates/commands/ - Moved 3 skills from ~/.claude/skills/ to templates/skills/ - Team sharing was BROKEN without this (symlinks pointed to empty dirs) - Updated README with prominent consolidation step warning - Commands: list, remember, save, search, session, triggers - Skills: initialize-project, remember-this, memory ## HIGH PRIORITY FIXES: - ✅ Completed selective semantic indexing (removed TODO at line 878) - ✅ Fixed PostgreSQL references in health check (system uses SQLite) - ✅ Created comprehensive API documentation (docs/API_REFERENCE.md) - ✅ Added Depends import to fix authentication endpoints ## DOCUMENTATION: - Added complete API_REFERENCE.md (60+ endpoints documented) - Created HYBRID_INDEXING_INTEGRATION.md (5 KB architecture) - Updated README with API docs link + consolidation warning - Documented all hybrid indexing endpoints with examples ## IMPROVEMENTS: - Selective semantic indexing now actually ingests files (was placeholder) - Health check now correctly queries SQLite instead of PostgreSQL - All authentication endpoints now functional - Structural indexing stores as pure JSON (no embeddings) Impact: Team sharing now works, all features documented, critical bugs fixed. Tested: Pistn indexing (3,117 files in 3 seconds) ✅ 🚀 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 14:23:43 -05:00
#!/bin/bash
# save-to-mcp.sh - Save context to Claude OS
# Usage: save-to-mcp.sh "Document Title" "Content" "KB Name (optional)" "Category (optional)"
TITLE="${1:-Captured Context}"
CONTENT="${2:-}"
KB_NAME="${3:-project_memories}"
CRITICAL FIXES: Consolidate templates + API improvements This commit fixes several critical issues found during comprehensive review: ## CRITICAL FIX: Template Consolidation ⚠️ - Moved 6 commands from ~/.claude/commands/ to templates/commands/ - Moved 3 skills from ~/.claude/skills/ to templates/skills/ - Team sharing was BROKEN without this (symlinks pointed to empty dirs) - Updated README with prominent consolidation step warning - Commands: list, remember, save, search, session, triggers - Skills: initialize-project, remember-this, memory ## HIGH PRIORITY FIXES: - ✅ Completed selective semantic indexing (removed TODO at line 878) - ✅ Fixed PostgreSQL references in health check (system uses SQLite) - ✅ Created comprehensive API documentation (docs/API_REFERENCE.md) - ✅ Added Depends import to fix authentication endpoints ## DOCUMENTATION: - Added complete API_REFERENCE.md (60+ endpoints documented) - Created HYBRID_INDEXING_INTEGRATION.md (5 KB architecture) - Updated README with API docs link + consolidation warning - Documented all hybrid indexing endpoints with examples ## IMPROVEMENTS: - Selective semantic indexing now actually ingests files (was placeholder) - Health check now correctly queries SQLite instead of PostgreSQL - All authentication endpoints now functional - Structural indexing stores as pure JSON (no embeddings) Impact: Team sharing now works, all features documented, critical bugs fixed. Tested: Pistn indexing (3,117 files in 3 seconds) ✅ 🚀 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 14:23:43 -05:00
CATEGORY="${4:-General}"
# Sanitize KB name for URL
KB_ENCODED=$(echo "$KB_NAME" | sed 's/ /%20/g')
# Create timestamp
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
DATE=$(date +"%Y-%m-%d")
# Create document
DOC_CONTENT=$(cat <<EOF
# $TITLE
**Date Saved**: $DATE
**Time**: $TIMESTAMP
**Category**: $CATEGORY
---
## Context
$CONTENT
---
*Saved to Claude OS - Your AI Memory System*
EOF
)
# Save locally first
DOC_FILENAME=$(echo "$TITLE" | sed 's/[^a-zA-Z0-9]/_/g').md
DOC_PATH="/tmp/${DOC_FILENAME}"
echo "$DOC_CONTENT" > "$DOC_PATH"
# Upload to Claude OS
API_URL="http://localhost:8051"
RESPONSE=$(curl -s -X POST \
"$API_URL/api/kb/$KB_ENCODED/upload" \
-F "file=@$DOC_PATH" \
-w "\n%{http_code}")
HTTP_CODE=$(echo "$RESPONSE" | tail -n 1)
# Check response
if [[ "$HTTP_CODE" =~ ^(200|201)$ ]]; then
echo "✅ Saved to Claude OS"
echo "📁 KB: $KB_NAME"
echo "📄 Title: $TITLE"
echo "🏷️ Category: $CATEGORY"
echo "💾 Local: $DOC_PATH"
exit 0
else
echo "❌ Failed to save (HTTP $HTTP_CODE)"
echo "Response: $(echo "$RESPONSE" | sed '$d')"
exit 1
fi