Initial commit with translated description

This commit is contained in:
2026-03-29 09:37:21 +08:00
commit 670b0c7bef
5 changed files with 265 additions and 0 deletions

80
SKILL.md Normal file
View File

@@ -0,0 +1,80 @@
---
name: supermemory
description: "使用SuperMemory API存储和检索记忆。添加内容、搜索记忆并与您的知识库聊天。"
metadata: {"moltbot":{"emoji":"🧠","requires":{"env":["SUPERMEMORY_API_KEY"]},"primaryEnv":"SUPERMEMORY_API_KEY"},"user-invocable":true}
---
# SuperMemory
Store, search, and chat with your personal knowledge base using SuperMemory's API.
## Setup
Configure your SuperMemory API key:
```bash
export SUPERMEMORY_API_KEY="sm_oiZHA2HcwT4tqSKmA7cCoK_opSRFViNFNxbYqjkjpVNfjSPqQWCNoOBAcxKZkKBfRVVrEQDVxLWHJPvepxqwEPe"
```
## Usage
### Add a Memory
**Add content to your memory store:**
```bash
# Add a memory with content
supermemory add "Your memory content here"
# Add a memory with a specific description
supermemory add "Important project details" --description "Project requirements"
```
### Search Memories
**Search your stored memories:**
```bash
supermemory search "search query"
```
### Chat with Memories
**Chat with your memory database:**
```bash
supermemory chat "What do you know about my projects?"
```
## Implementation
### Add Memory
When user wants to store information:
```bash
bash /root/clawd/skills/supermemory/scripts/add-memory.sh "content" "description (optional)"
```
### Search Memories
When user wants to find something in their memories:
```bash
bash /root/clawd/skills/supermemory/scripts/search.sh "query"
```
### Chat with Memory Base
When user wants to query their memory database conversationally:
```bash
bash /root/clawd/skills/supermemory/scripts/chat.sh "question"
```
## Examples
**Store important information:**
- "Remember that my API key is xyz" → `supermemory add "My API key is xyz" --description "API credentials"`
- "Save this link for later" → `supermemory add "https://example.com" --description "Bookmarked link"`
**Find information:**
- "What did I save about Python?" → `supermemory search "Python"`
- "Find my notes on the project" → `supermemory search "project notes"`
**Query your knowledge:**
- "What do I know about the marketing strategy?" → `supermemory chat "What do I know about the marketing strategy?"`
- "Summarize what I've learned about AI" → `supermemory chat "Summarize what I've learned about AI"`

6
_meta.json Normal file
View File

@@ -0,0 +1,6 @@
{
"ownerId": "kn77af2r1sj476crn32d2z6q7d803xgh",
"slug": "supermemory",
"version": "1.0.0",
"publishedAt": 1769623551710
}

60
scripts/add-memory.sh Normal file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
# SuperMemory - Add Memory Script
# Usage: add-memory.sh "content" "description (optional)"
set -e
CONTENT="$1"
DESCRIPTION="$2"
if [ -z "$CONTENT" ]; then
echo "Error: No content provided"
echo "Usage: add-memory.sh \"content\" \"description (optional)\""
exit 1
fi
API_KEY="${SUPERMEMORY_API_KEY}"
if [ -z "$API_KEY" ]; then
echo "Error: SUPERMEMORY_API_KEY environment variable not set"
echo "Please set it with: export SUPERMEMORY_API_KEY=\"your-api-key\""
exit 1
fi
# Sanitize description: replace spaces with hyphens, keep only alphanumeric, hyphens, underscores
SANITIZED_DESC=$(echo "${DESCRIPTION:-clawdbot}" | tr -cd '[:alnum:]-_' | tr '[:upper:]' '[:lower:]')
# SuperMemory API endpoint (using the direct API)
API_URL="https://api.supermemory.ai/v3/documents"
# Prepare the request
DATA=$(cat <<EOF
{
"content": "$CONTENT",
"customId": "memory_$(date +%s)",
"containerTags": ["$SANITIZED_DESC"]
}
EOF
)
# Make the API request
RESPONSE=$(curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d "$DATA")
# Check for errors
if echo "$RESPONSE" | grep -q "error"; then
echo "Error adding memory: $RESPONSE"
exit 1
fi
# Success - extract the memory ID if available
MEMORY_ID=$(echo "$RESPONSE" | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
if [ -n "$MEMORY_ID" ]; then
echo "✓ Memory added successfully (ID: $MEMORY_ID)"
else
echo "✓ Memory added successfully"
fi
echo "$RESPONSE"

70
scripts/chat.sh Normal file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
# SuperMemory - Chat with Memories Script
# Usage: chat.sh "question"
# Note: Uses search to retrieve relevant memories and presents them
set -e
QUESTION="$1"
if [ -z "$QUESTION" ]; then
echo "Error: No question provided"
echo "Usage: chat.sh \"question\""
exit 1
fi
API_KEY="${SUPERMEMORY_API_KEY}"
if [ -z "$API_KEY" ]; then
echo "Error: SUPERMEMORY_API_KEY environment variable not set"
echo "Please set it with: export SUPERMEMORY_API_KEY=\"your-api-key\""
exit 1
fi
# SuperMemory API search endpoint (used for chat-like queries)
API_URL="https://api.supermemory.ai/v3/search"
# Prepare the request
DATA=$(cat <<EOF
{
"q": "$QUESTION",
"limit": 5
}
EOF
)
# Make the API request
RESPONSE=$(curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d "$DATA")
# Check for errors
if echo "$RESPONSE" | grep -q "error"; then
echo "Error querying memories: $RESPONSE"
exit 1
fi
# Parse and display results in a chat-like format
echo "Based on your memories:"
echo "---"
# Extract and display the relevant chunks
echo "$RESPONSE" | python3 -c "
import sys, json
data = json.load(sys.stdin)
results = data.get('results', [])
if not results:
print('No relevant memories found.')
else:
for i, result in enumerate(results, 1):
chunks = result.get('chunks', [])
for chunk in chunks:
content = chunk.get('content', '')
score = chunk.get('score', 0)
if content:
print(f'{i}. {content}')
print(f' (relevance: {score:.2f})')
print()
" 2>/dev/null || echo "$RESPONSE"

49
scripts/search.sh Normal file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
# SuperMemory - Search Memories Script
# Usage: search.sh "search query"
set -e
QUERY="$1"
if [ -z "$QUERY" ]; then
echo "Error: No search query provided"
echo "Usage: search.sh \"search query\""
exit 1
fi
API_KEY="${SUPERMEMORY_API_KEY}"
if [ -z "$API_KEY" ]; then
echo "Error: SUPERMEMORY_API_KEY environment variable not set"
echo "Please set it with: export SUPERMEMORY_API_KEY=\"your-api-key\""
exit 1
fi
# SuperMemory API search endpoint
API_URL="https://api.supermemory.ai/v3/search"
# Prepare the request
DATA=$(cat <<EOF
{
"q": "$QUERY",
"limit": 10
}
EOF
)
# Make the API request
RESPONSE=$(curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d "$DATA")
# Check for errors
if echo "$RESPONSE" | grep -q "error"; then
echo "Error searching memories: $RESPONSE"
exit 1
fi
# Parse and display results
echo "Search results for \"$QUERY\":"
echo "---"
echo "$RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$RESPONSE"