-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·134 lines (119 loc) · 5.45 KB
/
setup.sh
File metadata and controls
executable file
·134 lines (119 loc) · 5.45 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
130
131
132
133
134
#!/usr/bin/env bash
set -euo pipefail
# AgentSource Plugin — Setup Script
# Installs the CLI, saves API key, and registers the plugin with Claude Code.
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_DIR="$HOME/.agentsource"
BIN_DIR="$INSTALL_DIR/bin"
SESSIONS_DIR="$INSTALL_DIR/sessions"
CONFIG_FILE="$INSTALL_DIR/config.json"
CLAUDE_PLUGINS_DIR="$HOME/.claude/plugins"
echo "=== AgentSource Plugin Setup ==="
echo "Plugin directory : $PLUGIN_DIR"
echo "Install directory: $INSTALL_DIR"
echo ""
# ---------------------------------------------------------------------------
# 1. Verify Python 3
# ---------------------------------------------------------------------------
if ! command -v python3 &>/dev/null; then
echo "[ERROR] Python 3 not found. Please install Python 3.8+ and retry."
exit 1
fi
PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
PYTHON_MAJOR=$(python3 -c 'import sys; print(sys.version_info.major)')
PYTHON_MINOR=$(python3 -c 'import sys; print(sys.version_info.minor)')
if [ "$PYTHON_MAJOR" -lt 3 ] || { [ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 8 ]; }; then
echo "[ERROR] Python 3.8+ required. Found: $PYTHON_VERSION"
exit 1
fi
echo "[OK] Python $PYTHON_VERSION"
# ---------------------------------------------------------------------------
# 2. Create directory structure
# ---------------------------------------------------------------------------
mkdir -p "$BIN_DIR" "$SESSIONS_DIR"
echo "[OK] Directories created"
# ---------------------------------------------------------------------------
# 3. Install CLI
# ---------------------------------------------------------------------------
cp "$PLUGIN_DIR/bin/agentsource.py" "$BIN_DIR/agentsource.py"
chmod +x "$BIN_DIR/agentsource.py"
echo "[OK] CLI installed to $BIN_DIR/agentsource.py"
# ---------------------------------------------------------------------------
# 4. API key configuration
# ---------------------------------------------------------------------------
echo ""
if [ -n "${EXPLORIUM_API_KEY:-}" ]; then
echo "[OK] EXPLORIUM_API_KEY is set in environment"
read -r -p "Save it to ~/.agentsource/config.json for persistence? [y/N] " save_key
if [[ "${save_key:-}" =~ ^[Yy]$ ]]; then
printf '{\n "api_key": "%s"\n}\n' \
"$EXPLORIUM_API_KEY" > "$CONFIG_FILE"
chmod 600 "$CONFIG_FILE"
echo "[OK] API key saved to $CONFIG_FILE (mode 600)"
fi
else
echo "EXPLORIUM_API_KEY is not set."
read -r -p "Enter your Explorium API key (or press Enter to skip): " api_key
if [ -n "${api_key:-}" ]; then
printf '{\n "api_key": "%s"\n}\n' \
"$api_key" > "$CONFIG_FILE"
chmod 600 "$CONFIG_FILE"
echo "[OK] API key saved to $CONFIG_FILE (mode 600)"
echo ""
echo " Add this to your shell profile (~/.zshrc or ~/.bashrc) for future sessions:"
echo " export EXPLORIUM_API_KEY='$api_key'"
else
echo "[WARN] No API key configured. Set EXPLORIUM_API_KEY before using the plugin."
fi
fi
# ---------------------------------------------------------------------------
# 5. Smoke-test the CLI
# ---------------------------------------------------------------------------
echo ""
echo "Running CLI smoke test..."
if python3 "$BIN_DIR/agentsource.py" --help &>/dev/null; then
echo "[OK] CLI smoke test passed"
else
echo "[ERROR] CLI smoke test failed. Check your Python installation."
exit 1
fi
# ---------------------------------------------------------------------------
# 6. Register plugin with Claude Code (copy files)
# ---------------------------------------------------------------------------
echo ""
# Standard plugin location (local Claude Code)
PLUGIN_DEST="$CLAUDE_PLUGINS_DIR/agentsource-plugin"
mkdir -p "$PLUGIN_DEST"
cp -r "$PLUGIN_DIR/.claude-plugin" "$PLUGIN_DEST/"
cp -r "$PLUGIN_DIR/skills" "$PLUGIN_DEST/"
cp -r "$PLUGIN_DIR/bin" "$PLUGIN_DEST/"
echo "[OK] Plugin installed to $PLUGIN_DEST"
# Also copy to Cowork plugin cache (Claude desktop app uploads from here)
COWORK_BASE="$HOME/Library/Application Support/Claude/local-agent-mode-sessions"
if [ -d "$COWORK_BASE" ]; then
# Find all cowork plugin directories for this plugin
while IFS= read -r -d '' cowork_dest; do
cp -r "$PLUGIN_DIR/.claude-plugin" "$cowork_dest/"
cp -r "$PLUGIN_DIR/skills" "$cowork_dest/"
cp -r "$PLUGIN_DIR/bin" "$cowork_dest/"
echo "[OK] Cowork plugin updated: $cowork_dest"
done < <(find "$COWORK_BASE" -type d -name "agentsource-plugin" -path "*/marketplaces/*" -print0 2>/dev/null)
fi
# ---------------------------------------------------------------------------
# 7. Done
# ---------------------------------------------------------------------------
echo ""
echo "=== Setup Complete ==="
echo ""
echo "Optional: Add the CLI to your PATH:"
echo " echo 'export PATH=\"\$HOME/.agentsource/bin:\$PATH\"' >> ~/.zshrc"
echo ""
echo "Usage in Claude Code:"
echo " Open any project, then describe what you're looking for, e.g.:"
echo " 'Find CTOs at Series B SaaS companies in California'"
echo " 'Show me fintech companies using Stripe with 50-200 employees'"
echo " 'Get emails for VP Sales at companies that recently raised Series A'"
echo ""
echo "Direct CLI usage:"
echo " python3 ~/.agentsource/bin/agentsource.py --help"
echo " python3 ~/.agentsource/bin/agentsource.py autocomplete --entity-type businesses --field linkedin_category --query 'saas' --semantic"