-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·341 lines (306 loc) · 12.3 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·341 lines (306 loc) · 12.3 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#!/bin/bash
# Dex PKM - Installation Script
# This script sets up your development environment
set -e
# Quiet Node's noisy upstream deprecation warnings (e.g. DEP0040 "punycode is
# deprecated") so first-run install output stays clean. These originate from
# transitive dependencies / npm internals on newer Node versions, not from Dex,
# and are harmless. Preserves any NODE_OPTIONS the user already set.
export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--no-deprecation"
echo "🚀 Setting up Dex..."
echo ""
# Check for Command Line Tools on macOS (required for git)
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! xcode-select -p &> /dev/null; then
echo "⚠️ Command Line Developer Tools not found"
echo ""
echo "macOS will now prompt you to install them - this is required for git."
echo "Click 'Install' when the dialog appears (takes 2-3 minutes)."
echo ""
echo "Press Enter to continue..."
read -r
# Trigger the install prompt
xcode-select --install 2>/dev/null || true
echo ""
echo "⏳ Waiting for Command Line Tools installation..."
echo " (This window will continue once installation completes)"
echo ""
# Wait for installation to complete
until xcode-select -p &> /dev/null; do
sleep 5
done
echo "✅ Command Line Tools installed!"
echo ""
fi
fi
# Silently fix git remote to avoid Claude Desktop confusion
if git remote -v 2>/dev/null | grep -q "davekilleen/[Dd]ex"; then
git remote rename origin upstream 2>/dev/null || true
fi
# Check Git first (required for repo operations)
if ! command -v git &> /dev/null; then
echo "❌ Git is not installed"
echo ""
echo "Git is required to clone the repository and manage updates."
echo ""
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
echo "Download Git for Windows from: https://git-scm.com/download/win"
echo "After installing, restart your terminal and run ./install.sh again"
else
echo "Download Git from: https://git-scm.com"
echo "After installing, restart your terminal and run ./install.sh again"
fi
exit 1
fi
echo "✅ Git $(git --version | cut -d' ' -f3)"
# Check Node.js
if ! command -v node &> /dev/null; then
echo "❌ Node.js is not installed"
echo " Please install Node.js 18+ from https://nodejs.org/"
exit 1
fi
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
echo "❌ Node.js version must be 18 or higher (found v$NODE_VERSION)"
echo " Please upgrade from https://nodejs.org/"
exit 1
fi
echo "✅ Node.js $(node -v)"
# Check Python (required for Work MCP - task sync)
# Windows often uses 'python' instead of 'python3'
PYTHON_CMD=""
if command -v python3 &> /dev/null; then
PYTHON_CMD="python3"
elif command -v python &> /dev/null; then
# Verify it's Python 3, not Python 2
PYTHON_VERSION=$(python --version 2>&1 | grep "Python 3")
if [ -n "$PYTHON_VERSION" ]; then
PYTHON_CMD="python"
fi
fi
if [ -n "$PYTHON_CMD" ]; then
PYTHON_VERSION=$($PYTHON_CMD --version | cut -d' ' -f2)
PYTHON_MAJOR=$(echo $PYTHON_VERSION | cut -d'.' -f1)
PYTHON_MINOR=$(echo $PYTHON_VERSION | cut -d'.' -f2)
# Check if Python 3.10+
if [ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 10 ]; then
echo "❌ Python $PYTHON_VERSION found (too old)"
echo ""
echo "MCP SDK requires Python 3.10 or newer."
echo "You have Python $PYTHON_VERSION which is too old."
echo ""
echo "Install Python 3.10+:"
echo " Download the latest version from https://www.python.org/downloads/"
echo " After installing, restart your terminal and run ./install.sh again"
exit 1
fi
echo "✅ Python $PYTHON_VERSION"
# Determine venv paths for this platform
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
VENV_PYTHON=".venv/Scripts/python.exe"
VENV_PIP=".venv/Scripts/pip.exe"
else
VENV_PYTHON=".venv/bin/python"
VENV_PIP=".venv/bin/pip"
fi
else
echo "❌ Python 3 not found"
echo ""
echo "Python 3.10+ is required for MCP servers (task sync across all files)."
echo "Without it, tasks won't sync between meeting notes, person pages, and Tasks.md."
echo ""
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
echo "Install Python 3.10+:"
echo " 1. Download from https://www.python.org/downloads/"
echo " 2. Run the installer"
echo " 3. ⚠️ IMPORTANT: Check 'Add Python to PATH' during installation"
echo " 4. Restart your terminal"
echo " 5. Run ./install.sh again"
else
echo "Install Python 3.10+:"
echo " Mac: Download from https://www.python.org/downloads/"
echo " Or use Homebrew: brew install python3"
echo ""
echo "After installing, run ./install.sh again"
fi
exit 1
fi
# Check npx (required for MCP servers)
if ! command -v npx &> /dev/null; then
echo "⚠️ npx not found (usually bundled with Node.js)"
echo " Some MCP servers may not work without npx."
echo " Try reinstalling Node.js from https://nodejs.org/"
fi
# Install Node dependencies
echo ""
echo "📦 Installing dependencies..."
if command -v pnpm &> /dev/null; then
pnpm install
elif command -v npm &> /dev/null; then
npm install
else
echo "❌ Neither npm nor pnpm found"
exit 1
fi
# Skip .env creation - it's created during /setup if needed
# (Most users don't need API keys - everything works through Cursor)
# Bootstrap-only configuration is owned by the sanctioned provision contract.
# This is the one legitimate pre-lifecycle write window: a fresh bundle does
# not yet have an activated lifecycle engine. Post-install adoption below uses
# the frozen lifecycle service.
echo ""
echo "📝 Converging bootstrap configuration through the provision contract..."
PROVISION_ARGS=(--path "$(pwd)" --install-config-only --json)
if command -v qmd &> /dev/null; then
PROVISION_ARGS+=(--enable-qmd)
fi
node core/provision.cjs "${PROVISION_ARGS[@]}" >/dev/null
if command -v qmd &> /dev/null; then
echo " qmd MCP server added when configuration was absent"
else
echo " semantic search not installed — run /enable-semantic-search to add it later"
fi
echo " MCP servers configured for: $(pwd)"
# Check for the optional Granola app. API access is connected separately.
echo ""
if [ -d "/Applications/Granola.app" ]; then
echo "✅ Granola app detected — run /granola-setup to connect it (needs a Granola Business API key)"
else
echo "ℹ️ Granola app not detected"
echo " Install Granola from https://granola.ai for meeting transcription"
echo " Then run /granola-setup to connect it (needs a Granola Business API key)"
fi
# Install Python dependencies for Work MCP in a virtual environment
echo ""
echo "📦 Setting up Python environment for Work MCP..."
if [ -n "$PYTHON_CMD" ]; then
# Create venv if it doesn't exist
if [ ! -d ".venv" ]; then
echo " Creating virtual environment..."
if ! $PYTHON_CMD -m venv .venv 2>/dev/null; then
echo "❌ Could not create virtual environment"
echo ""
echo "Try manually:"
echo " $PYTHON_CMD -m venv .venv"
echo " $VENV_PIP install -r core/mcp/requirements.txt"
echo ""
read -p "Press Enter to continue setup (you can fix this later)..."
fi
fi
# Install dependencies into venv
if [ -f "$VENV_PIP" ] && "$VENV_PIP" install -r core/mcp/requirements.txt --quiet 2>/dev/null; then
echo "✅ Work MCP dependencies installed"
else
echo "❌ Could not install Python dependencies"
echo ""
echo "Work MCP is critical - it syncs tasks across all your files."
echo "Without it, checking off a task in one place won't update others."
echo ""
echo "Try manually:"
echo " $PYTHON_CMD -m venv .venv"
echo " $VENV_PIP install -r core/mcp/requirements.txt"
echo ""
read -p "Press Enter to continue setup (you can fix this later)..."
fi
fi
# Verify Work MCP setup
echo ""
echo "🔍 Verifying Work MCP setup..."
if [ -n "$PYTHON_CMD" ] && [ -f "$VENV_PYTHON" ]; then
if "$VENV_PYTHON" -c "import mcp, yaml" 2>/dev/null; then
echo "✅ Work MCP verified - task sync will work"
WORK_MCP_STATUS="✅ Working"
# Path constants were generated by the sanctioned provision contract.
echo "Path constants generated"
else
echo "⚠️ Work MCP not working - task sync won't function"
WORK_MCP_STATUS="⚠️ Needs attention"
fi
else
WORK_MCP_STATUS="⚠️ Needs attention"
fi
# Converge Git clones to the split Brain/Vault topology through the migration
# engine that also handles existing installs. A bounded migration may ask to
# resume, so keep routing back to that engine until it reaches a terminal state.
echo ""
echo "🔀 Separating the Dex brain from your vault..."
MIGRATOR="core/migrations/v1-to-v2-brain-vault-split.cjs"
if [ ! -f "$MIGRATOR" ]; then
echo "❌ Dex cannot finish the brain/vault setup because the migrator is missing."
echo " Get a complete Dex release and run ./install.sh again."
exit 1
fi
MIGRATION_SYNC_FOLDER_ARGUMENT=""
for INSTALL_ARGUMENT in "$@"; do
if [ "$INSTALL_ARGUMENT" = "--allow-synced-folder" ]; then
MIGRATION_SYNC_FOLDER_ARGUMENT="--allow-synced-folder"
fi
done
MIGRATION_MODE="--auto"
while true; do
if [ -n "$MIGRATION_SYNC_FOLDER_ARGUMENT" ]; then
if node "$MIGRATOR" "$MIGRATION_MODE" "$MIGRATION_SYNC_FOLDER_ARGUMENT"; then
MIGRATION_STATUS=0
else
MIGRATION_STATUS=$?
fi
elif node "$MIGRATOR" "$MIGRATION_MODE"; then
MIGRATION_STATUS=0
else
MIGRATION_STATUS=$?
fi
if [ "$MIGRATION_STATUS" -eq 75 ]; then
MIGRATION_MODE="--resume"
continue
fi
if [ "$MIGRATION_STATUS" -ne 0 ]; then
echo "❌ Dex could not finish the brain/vault split."
echo " Read System/migration-report-v2.md, fix the reported issue, then run ./install.sh again."
exit "$MIGRATION_STATUS"
fi
break
done
if [ -f "System/.dex/topology.json" ] && [ -d ".dex/brain.git" ]; then
echo "✅ Your vault and the Dex brain now have separate Git histories"
else
echo "⚠️ This folder has no Git clone history, so the brain/vault split was not started."
echo " Your files are unchanged, and Dex will keep using the combined layout."
echo " Read System/migration-report-v2.md for the safe manual-update choices."
fi
# Any catalog adoption after bootstrap crosses the frozen lifecycle service;
# the provisioner only collects the vault path and renders its receipt.
DEX_ADOPTION_PYTHON="$PYTHON_CMD"
if [ -n "$VENV_PYTHON" ] && [ -f "$VENV_PYTHON" ]; then
DEX_ADOPTION_PYTHON="$VENV_PYTHON"
fi
DEX_LIFECYCLE_PYTHON="$DEX_ADOPTION_PYTHON" node core/provision.cjs --path "$(pwd)" --adopt --lifecycle-only
# Tell the user which chat app to use for the final setup step.
if command -v claude &> /dev/null; then
DEX_CHAT_APP="Claude Code"
elif command -v cursor &> /dev/null || { [[ "$OSTYPE" == "darwin"* ]] && [ -d "/Applications/Cursor.app" ]; }; then
DEX_CHAT_APP="Cursor"
else
DEX_CHAT_APP="your AI app"
fi
# Success
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ Dex installation complete!"
echo ""
echo "Status:"
echo " • Node.js: ✅ Working"
echo " • Work MCP: $WORK_MCP_STATUS"
if [[ "$WORK_MCP_STATUS" == *"Needs"* ]]; then
echo ""
echo "⚠️ IMPORTANT: Work MCP enables task sync across all files."
echo " Without it, Dex works but tasks won't sync automatically."
echo " See troubleshooting above to fix."
fi
echo ""
echo "Next steps:"
echo " 1. Open $DEX_CHAT_APP in this folder"
echo " (the folder you just installed into — not somewhere else)"
echo " 2. In $DEX_CHAT_APP chat, type: /setup"
echo " 3. Answer the setup questions (~5 minutes)"
echo " 4. Start using Dex!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"