fixup! chore: update marketplace for v0.11.37

march-improvements
This commit is contained in:
2026-03-06 15:39:52 +00:00
parent 1a6f6b6e5e
commit 77f5f02510
32 changed files with 2404 additions and 2778 deletions
+135 -85
View File
@@ -7,6 +7,8 @@
set -e
INSTALLER_VERSION="1.1.0"
# Configuration
GITHUB_REPO="lukaszraczylo/claude-mnemonic"
INSTALL_DIR="$HOME/.claude/plugins/marketplaces/claude-mnemonic"
@@ -40,6 +42,50 @@ error() {
exit 1
}
# Gracefully stop worker processes (SIGTERM first, then SIGKILL after timeout)
graceful_stop_worker() {
# Send SIGTERM first
pkill -TERM -f 'claude-mnemonic.*worker' 2>/dev/null || true
pkill -TERM -f '\.claude/plugins/.*/worker' 2>/dev/null || true
if command -v lsof &> /dev/null; then
lsof -ti :37777 2>/dev/null | xargs kill -TERM 2>/dev/null || true
elif command -v ss &> /dev/null; then
ss -tlnp 'sport = :37777' 2>/dev/null | awk 'NR>1 {print $6}' | grep -oP 'pid=\K[0-9]+' | xargs -r kill -TERM 2>/dev/null || true
elif command -v fuser &> /dev/null; then
fuser -k -TERM 37777/tcp 2>/dev/null || true
fi
# Wait up to 5 seconds for graceful shutdown
local waited=0
while [[ $waited -lt 5 ]]; do
if ! pgrep -f 'claude-mnemonic.*worker' &>/dev/null && ! pgrep -f '\.claude/plugins/.*/worker' &>/dev/null; then
return 0
fi
sleep 1
waited=$((waited + 1))
done
# Force kill if still running
pkill -9 -f 'claude-mnemonic.*worker' 2>/dev/null || true
pkill -9 -f '\.claude/plugins/.*/worker' 2>/dev/null || true
if command -v lsof &> /dev/null; then
lsof -ti :37777 2>/dev/null | xargs kill -9 2>/dev/null || true
elif command -v ss &> /dev/null; then
ss -tlnp 'sport = :37777' 2>/dev/null | awk 'NR>1 {print $6}' | grep -oP 'pid=\K[0-9]+' | xargs -r kill -9 2>/dev/null || true
elif command -v fuser &> /dev/null; then
fuser -k 37777/tcp 2>/dev/null || true
fi
sleep 1
# Remove stale PID cache to prevent hooks from using old worker info
rm -f "$HOME/.claude-mnemonic/.worker-cache" 2>/dev/null || true
# Verify process is gone
if pgrep -f 'claude-mnemonic.*worker' &>/dev/null; then
warn "Could not stop existing worker process"
fi
}
# Detect OS and architecture
detect_platform() {
local os arch
@@ -131,7 +177,7 @@ download_release() {
local tmp_dir
tmp_dir=$(mktemp -d)
trap "rm -rf $tmp_dir" EXIT
trap 'rm -rf "$tmp_dir"' EXIT
# Construct download URL (use .zip for Windows, .tar.gz for others)
local archive_ext="tar.gz"
@@ -147,8 +193,35 @@ download_release() {
error "Failed to download release from: $download_url"
fi
# Verify download integrity via checksum
local checksum_url="${download_url}.sha256"
info "Verifying download integrity..."
if curl -sSL -o "$tmp_dir/checksum.sha256" "$checksum_url" 2>/dev/null; then
local expected_hash actual_hash
expected_hash=$(awk '{print $1}' "$tmp_dir/checksum.sha256")
if command -v shasum &> /dev/null; then
actual_hash=$(shasum -a 256 "$tmp_dir/release.${archive_ext}" | awk '{print $1}')
elif command -v sha256sum &> /dev/null; then
actual_hash=$(sha256sum "$tmp_dir/release.${archive_ext}" | awk '{print $1}')
else
warn "No SHA256 tool found (shasum or sha256sum), skipping checksum verification"
actual_hash=""
fi
if [[ -n "$actual_hash" ]]; then
if [[ "$expected_hash" != "$actual_hash" ]]; then
error "Checksum verification failed! Expected: $expected_hash Got: $actual_hash"
fi
success "Checksum verified"
fi
else
warn "No checksum file available at $checksum_url, skipping verification"
fi
info "Extracting archive..."
if [[ "$archive_ext" == "zip" ]]; then
if ! command -v unzip &> /dev/null; then
error "unzip is required for Windows archives but not installed"
fi
if ! unzip -q "$tmp_dir/release.zip" -d "$tmp_dir"; then
error "Failed to extract archive"
fi
@@ -160,17 +233,7 @@ download_release() {
# Stop existing worker if running
info "Stopping existing worker (if running)..."
pkill -9 -f 'claude-mnemonic.*worker' 2>/dev/null || true
pkill -9 -f '\.claude/plugins/.*/worker' 2>/dev/null || true
# Kill process on port 37777 (use lsof on macOS, ss/fuser on Linux)
if command -v lsof &> /dev/null; then
lsof -ti :37777 | xargs kill -9 2>/dev/null || true
elif command -v ss &> /dev/null; then
ss -tlnp 'sport = :37777' 2>/dev/null | awk 'NR>1 {print $6}' | grep -oP 'pid=\K[0-9]+' | xargs -r kill -9 2>/dev/null || true
elif command -v fuser &> /dev/null; then
fuser -k 37777/tcp 2>/dev/null || true
fi
sleep 1
graceful_stop_worker
# Create installation directories
info "Installing to ${INSTALL_DIR}..."
@@ -178,13 +241,21 @@ download_release() {
mkdir -p "$INSTALL_DIR/.claude-plugin"
mkdir -p "$INSTALL_DIR/commands"
# Copy binaries
cp "$tmp_dir/worker" "$INSTALL_DIR/"
cp "$tmp_dir/mcp-server" "$INSTALL_DIR/"
cp "$tmp_dir/hooks/"* "$INSTALL_DIR/hooks/"
# Copy binaries (abort on failure — could indicate disk full or permissions issue)
if ! cp "$tmp_dir/worker" "$INSTALL_DIR/"; then
error "Failed to copy worker binary to $INSTALL_DIR/"
fi
if ! cp "$tmp_dir/mcp-server" "$INSTALL_DIR/"; then
error "Failed to copy mcp-server binary to $INSTALL_DIR/"
fi
if ! cp "$tmp_dir/hooks/"* "$INSTALL_DIR/hooks/"; then
error "Failed to copy hook binaries to $INSTALL_DIR/hooks/"
fi
# Copy plugin configuration
cp "$tmp_dir/.claude-plugin/"* "$INSTALL_DIR/.claude-plugin/"
if ! cp "$tmp_dir/.claude-plugin/"* "$INSTALL_DIR/.claude-plugin/"; then
error "Failed to copy plugin configuration to $INSTALL_DIR/.claude-plugin/"
fi
# Copy slash commands if they exist in the release
if [[ -d "$tmp_dir/commands" ]]; then
@@ -338,72 +409,51 @@ start_worker() {
error "Worker binary not found at $worker_path"
fi
# Check for port conflict with a non-mnemonic process
if command -v lsof &> /dev/null; then
local port_pid
port_pid=$(lsof -ti :37777 2>/dev/null || true)
if [[ -n "$port_pid" ]]; then
local port_cmd
port_cmd=$(ps -p "$port_pid" -o comm= 2>/dev/null || true)
if [[ -n "$port_cmd" ]] && ! echo "$port_cmd" | grep -q "worker"; then
warn "Port 37777 is in use by another process: $port_cmd (PID $port_pid)"
warn "The worker may fail to start. Consider stopping the conflicting process."
fi
fi
fi
info "Starting worker service..."
nohup "$worker_path" > /tmp/claude-mnemonic-worker.log 2>&1 &
sleep 2
# Retry health check up to 5 times with 1s interval
local retries=0
local max_retries=5
while [[ $retries -lt $max_retries ]]; do
sleep 1
if curl -sS http://localhost:37777/health > /dev/null 2>&1; then
success "Worker started successfully at http://localhost:37777"
return 0
fi
retries=$((retries + 1))
done
if curl -sS http://localhost:37777/health > /dev/null 2>&1; then
success "Worker started successfully at http://localhost:37777"
else
warn "Worker may not have started properly. Check /tmp/claude-mnemonic-worker.log"
fi
warn "Worker may not have started properly after ${max_retries} attempts. Check /tmp/claude-mnemonic-worker.log"
}
# Check optional dependencies for semantic search
check_optional_deps() {
local missing_deps=()
local install_hints=""
# Semantic search uses embedded ONNX runtime - no external Python/uvx dependencies needed
success "Semantic search enabled (embedded ONNX runtime)"
}
# Check for Python 3.13+
if command -v python3 &> /dev/null; then
local py_version=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null)
if [[ "$py_version" < "3.13" ]]; then
missing_deps+=("Python 3.13+ (found $py_version)")
fi
else
missing_deps+=("Python 3.13+")
fi
# Check for uvx
if ! command -v uvx &> /dev/null; then
missing_deps+=("uvx")
fi
if [[ ${#missing_deps[@]} -gt 0 ]]; then
echo ""
warn "Optional dependencies missing (needed for semantic search):"
for dep in "${missing_deps[@]}"; do
echo " - $dep"
done
echo ""
# Detect OS and show appropriate install command
case "$(uname -s)" in
Darwin)
info "Install on macOS:"
echo " brew install python@3.13"
echo " pip3 install uv"
;;
Linux)
info "Install on Linux:"
echo " sudo apt install python3 python3-pip"
echo " pip3 install uv"
;;
MINGW*|MSYS*|CYGWIN*)
info "Install on Windows:"
echo " winget install Python.Python.3.13"
echo " pip install uv"
;;
esac
echo ""
info "Note: Requires Python 3.13+. Most package managers install the latest version."
echo ""
info "Semantic search will be disabled until these are installed."
info "Core functionality (SQLite storage, full-text search) will work."
echo ""
else
success "Optional dependencies found (semantic search enabled)"
# Rollback partially installed files on failure
INSTALL_COMPLETE=false
cleanup_on_failure() {
if [[ "$INSTALL_COMPLETE" != "true" ]]; then
warn "Installation did not complete — cleaning up partial install..."
rm -rf "$INSTALL_DIR" 2>/dev/null || true
rm -rf "$CACHE_DIR" 2>/dev/null || true
fi
}
@@ -411,6 +461,8 @@ check_optional_deps() {
main() {
local version="${1:-}"
trap cleanup_on_failure EXIT
echo ""
echo "╔═══════════════════════════════════════════════════════════╗"
echo "║ Claude Mnemonic - Installation Script ║"
@@ -455,6 +507,8 @@ main() {
# Check optional dependencies
check_optional_deps
INSTALL_COMPLETE=true
echo ""
echo "╔═══════════════════════════════════════════════════════════╗"
echo "║ Installation Complete! ║"
@@ -467,6 +521,12 @@ main() {
echo ""
}
# Handle --version flag
if [[ "${1:-}" == "--version" ]]; then
echo "claude-mnemonic installer v${INSTALLER_VERSION}"
exit 0
fi
# Handle --register-only flag
if [[ "${1:-}" == "--register-only" ]]; then
version=$(cat "$INSTALL_DIR/.claude-plugin/plugin.json" 2>/dev/null | grep '"version"' | sed -E 's/.*"([^"]+)".*/\1/' || echo "1.0.0")
@@ -486,17 +546,7 @@ if [[ "${1:-}" == "--uninstall" ]]; then
echo ""
info "Stopping worker processes..."
pkill -9 -f 'claude-mnemonic.*worker' 2>/dev/null || true
pkill -9 -f '\.claude/plugins/.*/worker' 2>/dev/null || true
# Kill process on port 37777 (use lsof on macOS, ss/fuser on Linux)
if command -v lsof &> /dev/null; then
lsof -ti :37777 | xargs kill -9 2>/dev/null || true
elif command -v ss &> /dev/null; then
ss -tlnp 'sport = :37777' 2>/dev/null | awk 'NR>1 {print $6}' | grep -oP 'pid=\K[0-9]+' | xargs -r kill -9 2>/dev/null || true
elif command -v fuser &> /dev/null; then
fuser -k 37777/tcp 2>/dev/null || true
fi
sleep 1
graceful_stop_worker
info "Removing plugin directories..."
rm -rf "$INSTALL_DIR"
+55 -13
View File
@@ -16,6 +16,35 @@ CACHE_BASE="$HOME/.claude/plugins/cache/claude-mnemonic/claude-mnemonic"
CACHE_PATH="$CACHE_BASE/$VERSION"
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
# Helper: safely write JSON via tmp file with validation
# Usage: safe_jq_write <jq_args...> <input_file>
# The last argument is treated as the input file, output goes to input_file.tmp
safe_jq_write() {
local args=("$@")
local input_file="${args[-1]}"
local tmp_file="${input_file}.tmp"
if jq "${args[@]}" > "$tmp_file"; then
if jq . "$tmp_file" > /dev/null 2>&1; then
mv "$tmp_file" "$input_file"
else
echo "ERROR: jq produced invalid JSON for $input_file, aborting"
rm -f "$tmp_file"
return 1
fi
else
echo "ERROR: jq failed for $input_file, aborting"
rm -f "$tmp_file"
return 1
fi
}
# Check that Claude Code directory exists
if [ ! -d "$HOME/.claude" ]; then
echo "Warning: $HOME/.claude directory not found. Claude Code may not be installed."
echo "Continuing anyway, but plugin may not function until Claude Code is installed."
fi
# Ensure plugins directory exists
mkdir -p "$HOME/.claude/plugins"
@@ -42,6 +71,24 @@ fi
# Check if jq is available
if command -v jq &> /dev/null; then
# Validate jq version (1.6+ required for //= operator)
JQ_VERSION=$(jq --version 2>/dev/null | sed 's/jq-//')
JQ_MAJOR=$(echo "$JQ_VERSION" | cut -d. -f1)
JQ_MINOR=$(echo "$JQ_VERSION" | cut -d. -f2)
if [ -n "$JQ_MAJOR" ] && [ -n "$JQ_MINOR" ]; then
if [ "$JQ_MAJOR" -lt 1 ] || { [ "$JQ_MAJOR" -eq 1 ] && [ "$JQ_MINOR" -lt 6 ]; }; then
echo "ERROR: jq 1.6+ is required (found jq-$JQ_VERSION)"
echo "Please upgrade jq: brew install jq (macOS) or apt-get install jq (Linux)"
exit 1
fi
fi
# Validate marketplace path exists and contains expected files
if [ ! -d "$MARKETPLACE_PATH" ]; then
echo "Warning: Marketplace directory not found at $MARKETPLACE_PATH"
echo "Plugin files may not be copied to cache correctly."
fi
# Ensure cache directory exists and copy plugin files
mkdir -p "$CACHE_PATH/.claude-plugin"
mkdir -p "$CACHE_PATH/hooks"
@@ -64,9 +111,8 @@ EOF
)
# Add or update the plugin entry in installed_plugins.json
jq --arg key "$PLUGIN_KEY" --argjson entry "$PLUGIN_ENTRY" \
'.plugins[$key] = $entry' "$PLUGINS_FILE" > "${PLUGINS_FILE}.tmp" \
&& mv "${PLUGINS_FILE}.tmp" "$PLUGINS_FILE"
safe_jq_write --arg key "$PLUGIN_KEY" --argjson entry "$PLUGIN_ENTRY" \
'.plugins[$key] = $entry' "$PLUGINS_FILE"
echo "Plugin registered in installed_plugins.json"
@@ -82,9 +128,8 @@ EOF
EOF
)
jq --arg key "$PLUGIN_KEY" --argjson statusline "$STATUSLINE_ENTRY" \
'.enabledPlugins //= {} | .enabledPlugins[$key] = true | .statusLine = $statusline' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" \
&& mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
safe_jq_write --arg key "$PLUGIN_KEY" --argjson statusline "$STATUSLINE_ENTRY" \
'.enabledPlugins //= {} | .enabledPlugins[$key] = true | .statusLine = $statusline' "$SETTINGS_FILE"
echo "Plugin enabled in settings.json"
echo "Statusline configured in settings.json"
@@ -102,9 +147,8 @@ EOF
EOF
)
jq --arg key "$MARKETPLACE_NAME" --argjson entry "$MARKETPLACE_ENTRY" \
'.[$key] = $entry' "$MARKETPLACES_FILE" > "${MARKETPLACES_FILE}.tmp" \
&& mv "${MARKETPLACES_FILE}.tmp" "$MARKETPLACES_FILE"
safe_jq_write --arg key "$MARKETPLACE_NAME" --argjson entry "$MARKETPLACE_ENTRY" \
'.[$key] = $entry' "$MARKETPLACES_FILE"
echo "Marketplace registered in known_marketplaces.json"
@@ -126,13 +170,11 @@ EOF
MCP_ENTRY=$(echo "$MCP_ENTRY" | sed "s|MCP_BINARY_PLACEHOLDER|$MCP_BINARY|g")
# Add or update mcpServers field
if jq --arg key "claude-mnemonic" --argjson entry "$MCP_ENTRY" \
'.mcpServers //= {} | .mcpServers[$key] = $entry' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp"; then
mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
if safe_jq_write --arg key "claude-mnemonic" --argjson entry "$MCP_ENTRY" \
'.mcpServers //= {} | .mcpServers[$key] = $entry' "$SETTINGS_FILE"; then
echo "MCP server registered successfully"
else
echo "Warning: Failed to register MCP server (jq error)"
rm -f "${SETTINGS_FILE}.tmp"
fi
else
echo "MCP server binary not found at $MCP_BINARY, skipping MCP registration"
+16 -3
View File
@@ -3,6 +3,18 @@
set -e
# Stop running worker processes before removing binaries
echo "Stopping worker processes..."
pkill -TERM -f 'claude-mnemonic.*worker' 2>/dev/null || true
pkill -TERM -f '\.claude/plugins/.*/worker' 2>/dev/null || true
sleep 2
# Force kill if still running
pkill -9 -f 'claude-mnemonic.*worker' 2>/dev/null || true
pkill -9 -f '\.claude/plugins/.*/worker' 2>/dev/null || true
# Clean up port
lsof -ti :37777 | xargs kill -9 2>/dev/null || true
sleep 1
PLUGINS_FILE="$HOME/.claude/plugins/installed_plugins.json"
SETTINGS_FILE="$HOME/.claude/settings.json"
MARKETPLACES_FILE="$HOME/.claude/plugins/known_marketplaces.json"
@@ -30,16 +42,17 @@ else
echo "No plugins file found, skipping"
fi
# Remove from settings.json (enabledPlugins and statusLine if it points to our plugin)
# Remove from settings.json (enabledPlugins, statusLine, and mcpServers)
if [ -f "$SETTINGS_FILE" ]; then
# Remove from enabledPlugins and clear statusLine if it references our plugin
# Remove from enabledPlugins, clear statusLine if it references our plugin, and remove MCP server
jq --arg key "$PLUGIN_KEY" '
del(.enabledPlugins[$key]) |
if .statusLine.command and (.statusLine.command | contains("claude-mnemonic")) then
del(.statusLine)
else
.
end
end |
del(.mcpServers["claude-mnemonic"])
' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" \
&& mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
echo "Plugin removed from settings.json"