-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·129 lines (101 loc) · 3.44 KB
/
install.sh
File metadata and controls
executable file
·129 lines (101 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env bash
set -euo pipefail
# microtaskrr installer
# Usage: curl -fsSL https://raw.githubusercontent.com/whoisyurii/microtaskrr/main/install.sh | bash
REPO="whoisyurii/microtaskrr"
INSTALL_DIR="$HOME/.local/bin"
BINARY_NAME="microtaskrr"
SETTINGS_FILE="$HOME/.claude/settings.json"
echo ""
echo " ⚡ microtaskrr Installer"
echo " Mini-games while Claude thinks"
echo ""
# --- 1. Detect platform ---
OS="$(uname -s)"
ARCH="$(uname -m)"
if [ "$OS" != "Darwin" ]; then
echo " ✗ Sorry, microtaskrr only supports macOS for now."
exit 1
fi
if [ "$ARCH" = "arm64" ]; then
TARGET="aarch64-apple-darwin"
elif [ "$ARCH" = "x86_64" ]; then
TARGET="x86_64-apple-darwin"
else
echo " ✗ Unsupported architecture: $ARCH"
exit 1
fi
echo " → Platform: macOS $ARCH"
# --- 2. Download binary ---
echo " → Fetching latest release..."
LATEST_URL=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" \
| grep "browser_download_url.*${TARGET}" \
| head -1 \
| cut -d '"' -f 4)
if [ -z "$LATEST_URL" ]; then
echo " ✗ Could not find a release for $TARGET."
echo " → You can build from source instead:"
echo " git clone https://github.com/$REPO && cd microtaskrr"
echo " npm install && npx tauri build"
exit 1
fi
mkdir -p "$INSTALL_DIR"
TMP_FILE=$(mktemp)
echo " → Downloading $LATEST_URL"
curl -fsSL -o "$TMP_FILE" "$LATEST_URL"
chmod +x "$TMP_FILE"
mv "$TMP_FILE" "$INSTALL_DIR/$BINARY_NAME"
echo " ✓ Installed to $INSTALL_DIR/$BINARY_NAME"
# --- 3. Patch Claude Code settings ---
echo " → Configuring Claude Code hooks..."
mkdir -p "$(dirname "$SETTINGS_FILE")"
HOOK_COMMAND="$INSTALL_DIR/$BINARY_NAME show &"
# Create settings file if it doesn't exist
if [ ! -f "$SETTINGS_FILE" ]; then
echo '{}' > "$SETTINGS_FILE"
fi
# Use python3 (ships with macOS) to safely merge the hook into existing settings
python3 << 'PYEOF'
import json, sys, os
settings_path = os.path.expanduser("~/.claude/settings.json")
bin_path = os.path.expanduser("~/.local/bin/microtaskrr")
hook_cmd = f"{bin_path} show &"
with open(settings_path, "r") as f:
try:
settings = json.load(f)
except json.JSONDecodeError:
settings = {}
if not isinstance(settings, dict):
settings = {}
# Ensure hooks structure exists
hooks = settings.setdefault("hooks", {})
# Add hooks for UserPromptSubmit and PreCompact if not already present
for event in ["UserPromptSubmit", "PreCompact"]:
entries = hooks.setdefault(event, [])
already_has = any(
any(h.get("command", "").startswith(bin_path) for h in entry.get("hooks", []))
for entry in entries
)
if not already_has:
entries.append({
"matcher": "",
"hooks": [{"type": "command", "command": hook_cmd}]
})
with open(settings_path, "w") as f:
json.dump(settings, f, indent=2)
f.write("\n")
print(" ✓ Claude Code hooks configured")
PYEOF
# --- 4. Start the background process ---
# Kill any existing microtaskrr process
pkill -f "$INSTALL_DIR/$BINARY_NAME" 2>/dev/null || true
sleep 0.5
nohup "$INSTALL_DIR/$BINARY_NAME" > /dev/null 2>&1 &
echo " ✓ microtaskrr is running in the background"
echo ""
echo " ✅ All done! Start a new Claude Code session and send a prompt."
echo " A mini-game will pop up while Claude thinks."
echo " Press Esc to dismiss and return to your terminal."
echo ""
echo " To uninstall: bash <(curl -fsSL https://raw.githubusercontent.com/$REPO/main/uninstall.sh)"
echo ""