forked from knowsuchagency/fulcrum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmise.toml
More file actions
879 lines (743 loc) · 26.4 KB
/
Copy pathmise.toml
File metadata and controls
879 lines (743 loc) · 26.4 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
[env]
_.file = ".env"
# Default FULCRUM_DIR for dev - can be overridden via env var before running mise
FULCRUM_DIR = "{{ env.FULCRUM_DIR | default(value='~/tmp/fulcrum') }}"
[tools]
bun = "latest"
[hooks]
postinstall = "bun install"
[tasks.install]
description = "Install dependencies"
run = "bun install"
[tasks.bump]
description = "Bump version (major, minor, or patch)"
usage = '''
arg "[type]" help="Version type: major, minor, or patch" default="patch"
flag "-c --commit" help="Auto-commit after bumping"
'''
run = """
#!/usr/bin/env bash
set -e
current=$(jq -r '.version' package.json)
IFS='.' read -r major minor patch <<< "$current"
case "${usage_type}" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
*) echo "Invalid type: ${usage_type}. Use major, minor, or patch" >&2; exit 1 ;;
esac
new_version="$major.$minor.$patch"
# Update package.json
jq --arg v "$new_version" '.version = $v' package.json > package.json.tmp && mv package.json.tmp package.json
echo "Updated package.json: $current → $new_version"
# Update plugin marketplace.json
marketplace=".claude-plugin/marketplace.json"
if [ -f "$marketplace" ]; then
jq --arg v "$new_version" '.plugins[0].version = $v' "$marketplace" > "${marketplace}.tmp" && mv "${marketplace}.tmp" "$marketplace"
echo "Updated $marketplace"
fi
# Update plugin.json
plugin="plugins/fulcrum/.claude-plugin/plugin.json"
if [ -f "$plugin" ]; then
jq --arg v "$new_version" '.version = $v' "$plugin" > "${plugin}.tmp" && mv "${plugin}.tmp" "$plugin"
echo "Updated $plugin"
fi
# Update plugin marketplace.json (installed plugin)
plugin_marketplace="plugins/fulcrum/.claude-plugin/marketplace.json"
if [ -f "$plugin_marketplace" ]; then
jq --arg v "$new_version" '.plugins[0].version = $v' "$plugin_marketplace" > "${plugin_marketplace}.tmp" && mv "${plugin_marketplace}.tmp" "$plugin_marketplace"
echo "Updated $plugin_marketplace"
fi
# Update neutralino.config.json
neutralino_config="desktop/neutralino.config.json"
if [ -f "$neutralino_config" ]; then
jq --arg v "$new_version" '.version = $v | .globalVariables.APP_VERSION = $v' "$neutralino_config" > "${neutralino_config}.tmp" && mv "${neutralino_config}.tmp" "$neutralino_config"
echo "Updated $neutralino_config"
fi
# Update settings schema version to match major version
settings_file="server/lib/settings/types.ts"
if [ -f "$settings_file" ]; then
current_schema=$(grep 'CURRENT_SCHEMA_VERSION = ' "$settings_file" | sed 's/[^0-9]//g')
if [ -n "$current_schema" ] && [ "$current_schema" != "$major" ]; then
# Use perl for cross-platform compatibility (macOS sed -i differs from GNU sed)
perl -i -pe "s/CURRENT_SCHEMA_VERSION = $current_schema/CURRENT_SCHEMA_VERSION = $major/" "$settings_file"
echo "Updated $settings_file: schema $current_schema → $major"
fi
fi
# Update MCP server versions
mcp_http="server/routes/mcp.ts"
if [ -f "$mcp_http" ]; then
perl -i -pe "s/version: '[0-9]+\\.[0-9]+\\.[0-9]+'/version: '$new_version'/" "$mcp_http"
echo "Updated $mcp_http"
fi
mcp_stdio="cli/src/mcp/index.ts"
if [ -f "$mcp_stdio" ]; then
perl -i -pe "s/version: '[0-9]+\\.[0-9]+\\.[0-9]+'/version: '$new_version'/" "$mcp_stdio"
echo "Updated $mcp_stdio"
fi
echo "Bumped version: $current → $new_version"
# Auto-commit if --commit flag is set
if [ "$usage_commit" = "true" ]; then
git add -A
git commit -m "chore: bump version to $new_version"
echo "Committed version bump"
fi
"""
[tasks.dev]
description = "Start frontend and backend dev servers"
depends = ["install"]
usage = '''
flag "--host" help="Bind frontend to all network interfaces (0.0.0.0)"
flag "--tailnet" help="Bind frontend to the tailscale IP only (backend stays on loopback)"
'''
run = """
# Ensure child processes are killed when this script exits
cleanup() {
# Kill entire process group
kill -- -$$ 2>/dev/null || true
}
trap cleanup EXIT INT TERM
FULCRUM_DIR="${FULCRUM_DIR:-$HOME/tmp/fulcrum}"
# Default dev port to 8888 (prod uses 7777), respect PORT env var if set
# Note: 6666 might conflict with 'cbt' (SSH tunnel) service on some systems.
# If you encounter "Address already in use", set PORT=8888 or similar in .env
PORT="${PORT:-8888}"
# Determine host binding. --tailnet wins if both are set: it's the safer option
# (only the tailscale interface, not the LAN). Backend always stays on
# loopback — Vite proxies /api and /ws to it.
if [ "$usage_tailnet" = "true" ]; then
if ! command -v tailscale >/dev/null 2>&1; then
echo "ERROR: --tailnet requires the tailscale CLI to be installed" >&2
exit 1
fi
TS_IP="$(tailscale ip -4 2>/dev/null | head -n1)"
if [ -z "$TS_IP" ]; then
echo "ERROR: --tailnet requires tailscale to be running and logged in" >&2
exit 1
fi
VITE_HOST="--host $TS_IP"
echo "Tailnet mode: frontend on http://$TS_IP:${FRONTEND_PORT:-5173}/" >&2
elif [ "$usage_host" = "true" ]; then
VITE_HOST="--host"
else
VITE_HOST=""
fi
VITE_BACKEND_PORT="$PORT"
DEBUG="1"
# Pass through env vars explicitly since they may not inherit through concurrently/bunx
# --kill-others ensures if one process dies, all are killed
bunx concurrently --kill-others -n server,client -c blue,green \
"FULCRUM_DIR=$FULCRUM_DIR PORT=$PORT mise run server" \
"DEBUG=$DEBUG VITE_BACKEND_PORT=$VITE_BACKEND_PORT VITE_HOST=\\"$VITE_HOST\\" mise run client"
"""
[tasks.server]
description = "Start backend dev server with auto-reload"
run = """
mkdir -p "${FULCRUM_DIR:-$HOME/.fulcrum}"
# Install OpenCode plugin from source (dev mode - always fresh)
OPENCODE_PLUGIN_DIR="$HOME/.config/opencode/plugin"
mkdir -p "$OPENCODE_PLUGIN_DIR"
cp plugins/fulcrum-opencode/index.ts "$OPENCODE_PLUGIN_DIR/fulcrum.ts"
echo "Installed OpenCode plugin from source" >&2
bun --watch server/index.ts
"""
[tasks.client]
description = "Start frontend dev server"
run = "DEBUG=\"${DEBUG:-}\" bunx vite --port \"${FRONTEND_PORT:-5173}\" ${VITE_HOST:-}"
[tasks.build]
description = "Build for production"
depends = ["install"]
run = """
rm -rf dist
bunx tsc -b --force && bunx vite build
"""
[tasks."build:debug"]
description = "Build for production with debug logging enabled"
run = """
rm -rf dist
bunx tsc -b --force && DEBUG=1 bunx vite build
"""
[tasks.start]
description = "Run production server"
depends = ["build"]
usage = 'flag "--host" help="Bind to all network interfaces (0.0.0.0)"'
run = """
if [ "$usage_host" = "true" ]; then
HOST="0.0.0.0"
else
HOST="localhost"
fi
NODE_ENV=production HOST="$HOST" bun server/index.ts
"""
[tasks.test]
description = "Run linter and all tests (quiet mode, errors only)"
usage = 'flag "-v" "--verbose" help="Show all test output"'
run = """
#!/usr/bin/env bash
set -e
set -o pipefail
# Run linter first (doesn't need isolation)
# Target specific source dirs to avoid traversing cli/dist, node_modules, .jj etc.
# React Compiler ESLint plugin (v7+) performs deep data flow analysis and needs extra heap
echo "Running linter..." >&2
NODE_OPTIONS='--max-old-space-size=4096' bunx eslint frontend/ server/ cli/src/ shared/ plugins/ || exit 1
# Create isolated test directories BEFORE bun starts.
# This is critical because Bun caches os.homedir() at process startup,
# before any JavaScript runs (including preload scripts).
# Setting HOME here ensures the cached value is the temp directory.
#
# HOME_BACKUP preserves the original HOME so test isolation code can
# detect and block access to production paths (~/.fulcrum, ~/.claude).
export HOME_BACKUP="$HOME"
export HOME=$(mktemp -d -t fulcrum-test-home-XXXXXX)
export FULCRUM_DIR=$(mktemp -d -t fulcrum-test-dir-XXXXXX)
echo "[test] Isolated environment: HOME=$HOME FULCRUM_DIR=$FULCRUM_DIR" >&2
# Run tests serially to avoid env var conflicts between test files
echo "Running tests..." >&2
if [ "$usage_verbose" = "true" ]; then
bun test --max-concurrency=1
else
# Filter to show only failures and summary (exclude diff lines starting with +/-)
bun test --max-concurrency=1 2>&1 | grep -v '^[+-]' | grep -E '(^bun test|[(]fail[)]|✗|expect[(]received[)]|^ *[0-9]+ (pass|fail|skip)|^Ran [0-9]+ tests)' || [ ${PIPESTATUS[0]} -eq 0 ]
fi
"""
[tasks."test:file"]
description = "Run specific test file(s) with isolation"
usage = 'arg "<files>..." help="Test file paths"'
run = """
#!/usr/bin/env bash
set -e
# Create isolated test directories before bun starts
# HOME_BACKUP preserves the original HOME for test isolation checks
export HOME_BACKUP="$HOME"
export HOME=$(mktemp -d -t fulcrum-test-home-XXXXXX)
export FULCRUM_DIR=$(mktemp -d -t fulcrum-test-dir-XXXXXX)
echo "[test:file] Isolated environment: HOME=$HOME FULCRUM_DIR=$FULCRUM_DIR" >&2
bun test ${usage_files}
"""
[tasks."test:watch"]
description = "Run tests in watch mode (with isolation)"
run = """
#!/usr/bin/env bash
set -e
# Create isolated test directories before bun starts
# HOME_BACKUP preserves the original HOME for test isolation checks
export HOME_BACKUP="$HOME"
export HOME=$(mktemp -d -t fulcrum-test-home-XXXXXX)
export FULCRUM_DIR=$(mktemp -d -t fulcrum-test-dir-XXXXXX)
echo "[test:watch] Isolated environment: HOME=$HOME FULCRUM_DIR=$FULCRUM_DIR" >&2
bun test --watch
"""
[tasks.lint]
description = "Run ESLint"
run = "NODE_OPTIONS='--max-old-space-size=4096' bunx eslint frontend/ server/ cli/src/ shared/ plugins/"
[tasks.typecheck]
description = "Check TypeScript types"
run = "bunx tsc --noEmit"
[tasks.check]
description = "Run all checks (lint + typecheck + version)"
depends = ["lint", "typecheck", "check:version"]
[tasks."check:version"]
description = "Verify all version files are in sync"
run = """
#!/usr/bin/env bash
set -e
# Source of truth
VERSION=$(jq -r '.version' package.json)
# Files to check
MARKETPLACE=".claude-plugin/marketplace.json"
PLUGIN="plugins/fulcrum/.claude-plugin/plugin.json"
NEUTRALINO="desktop/neutralino.config.json"
errors=0
# Check marketplace.json
if [ -f "$MARKETPLACE" ]; then
MARKETPLACE_VERSION=$(jq -r '.plugins[0].version' "$MARKETPLACE")
if [ "$MARKETPLACE_VERSION" != "$VERSION" ]; then
echo "ERROR: $MARKETPLACE version ($MARKETPLACE_VERSION) != package.json ($VERSION)" >&2
errors=$((errors + 1))
fi
fi
# Check plugin.json
if [ -f "$PLUGIN" ]; then
PLUGIN_VERSION=$(jq -r '.version' "$PLUGIN")
if [ "$PLUGIN_VERSION" != "$VERSION" ]; then
echo "ERROR: $PLUGIN version ($PLUGIN_VERSION) != package.json ($VERSION)" >&2
errors=$((errors + 1))
fi
fi
# Check plugin marketplace.json
PLUGIN_MARKETPLACE="plugins/fulcrum/.claude-plugin/marketplace.json"
if [ -f "$PLUGIN_MARKETPLACE" ]; then
PLUGIN_MARKETPLACE_VERSION=$(jq -r '.plugins[0].version' "$PLUGIN_MARKETPLACE")
if [ "$PLUGIN_MARKETPLACE_VERSION" != "$VERSION" ]; then
echo "ERROR: $PLUGIN_MARKETPLACE version ($PLUGIN_MARKETPLACE_VERSION) != package.json ($VERSION)" >&2
errors=$((errors + 1))
fi
fi
# Check neutralino.config.json (has two version fields)
if [ -f "$NEUTRALINO" ]; then
NL_VERSION=$(jq -r '.version' "$NEUTRALINO")
NL_APP_VERSION=$(jq -r '.globalVariables.APP_VERSION' "$NEUTRALINO")
if [ "$NL_VERSION" != "$VERSION" ]; then
echo "ERROR: $NEUTRALINO .version ($NL_VERSION) != package.json ($VERSION)" >&2
errors=$((errors + 1))
fi
if [ "$NL_APP_VERSION" != "$VERSION" ]; then
echo "ERROR: $NEUTRALINO .globalVariables.APP_VERSION ($NL_APP_VERSION) != package.json ($VERSION)" >&2
errors=$((errors + 1))
fi
fi
if [ $errors -gt 0 ]; then
echo "" >&2
echo "Version mismatch detected! Run 'mise run bump' to sync all versions." >&2
exit 1
fi
echo "All versions in sync: $VERSION"
# Show schema version (informational)
if [ -f "server/lib/settings.ts" ]; then
SCHEMA_VERSION=$(grep '^const CURRENT_SCHEMA_VERSION' server/lib/settings.ts | sed 's/.*= //')
echo "Settings schema version: $SCHEMA_VERSION"
fi
"""
[tasks.preview]
description = "Preview production build"
run = "bunx vite preview"
[tasks."db:studio"]
description = "Open Drizzle Studio GUI"
run = "bun run drizzle-kit studio"
[tasks."db:generate"]
description = "Generate migrations"
raw = true # drizzle-kit may prompt for table rename decisions
run = "bun run drizzle-kit generate"
[tasks."db:migrate"]
description = "Apply migrations"
run = "bun run drizzle-kit migrate"
# CLI tasks
[tasks."cli"]
description = "Run CLI command"
usage = 'arg "[args]..." help="Arguments to pass to CLI" default=""'
run = "bun cli/src/index.ts ${usage_args}"
[tasks."cli:link"]
description = "Link CLI for global access"
dir = "cli"
run = "bun link"
[tasks."cli:typecheck"]
description = "Typecheck CLI"
run = "bunx tsc --noEmit -p cli/tsconfig.json"
[tasks."cli:bundle"]
description = "Bundle CLI package for npm distribution"
depends = ["build"]
run = """
set -e
# Generate cli/package.json from root package.json
echo "Generating cli/package.json..." >&2
jq '{
name,
version,
description,
license,
repository: {type: "git", url: "https://github.com/knowsuchagency/fulcrum"},
homepage: "https://github.com/knowsuchagency/fulcrum",
type: "module",
bin: {fulcrum: "bin/fulcrum.js"},
files: ["bin/", "server/", "lib/", "dist/", "drizzle/", "README.md", "LICENSE"],
engines: {bun: ">=1.0.0"}
}' package.json > cli/package.json
# Bundle server
echo "Bundling server..." >&2
bun build server/index.ts --target=bun --outfile=cli/server/index.js
# Bundle CLI with node shebang
echo "Bundling CLI..." >&2
mkdir -p cli/bin
bun build cli/src/index.ts --target=bun --outfile=cli/bin/fulcrum.js
# Replace bun shebang with node (npm requirement) - bun is still invoked at runtime
# Use perl for cross-platform compatibility (macOS sed -i differs from GNU sed)
perl -i -pe 's|#!/usr/bin/env bun|#!/usr/bin/env node| if $. == 1' cli/bin/fulcrum.js
# Copy native PTY libraries (all platforms)
echo "Copying native PTY libraries..." >&2
mkdir -p cli/lib
cp node_modules/bun-pty/rust-pty/target/release/librust_pty.so cli/lib/ 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/librust_pty_arm64.so cli/lib/ 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/librust_pty.dylib cli/lib/ 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/librust_pty_arm64.dylib cli/lib/ 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/rust_pty.dll cli/lib/ 2>/dev/null || true
# Copy SQL migrations (generated during development via: mise run db:generate)
echo "Copying migrations..." >&2
mkdir -p cli/drizzle
cp -r drizzle/* cli/drizzle/
# Copy frontend build
echo "Copying frontend build..." >&2
mkdir -p cli/dist
cp -r dist/* cli/dist/
# Copy README and LICENSE
echo "Copying README and LICENSE..." >&2
cp README.md cli/
cp LICENSE cli/
echo "CLI bundle complete"
"""
[tasks."cli:build"]
description = "Build CLI package for npm distribution"
depends = ["cli:bundle"]
[tasks."cli:publish"]
description = "Publish CLI to npm"
depends = ["cli:build"]
dir = "cli"
usage = 'arg "<otp>" help="npm one-time password for 2FA"'
run = "npm publish --access public --otp=${usage_otp}"
# Migration task
[tasks.migrate-from-vibora]
description = "Migrate data from ~/.vibora to ~/.fulcrum"
usage = 'flag "-y" "--yes" help="Auto-confirm prompts"'
run = """
if [ "$usage_yes" = "true" ]; then
bun cli/src/index.ts migrate-from-vibora --yes
else
bun cli/src/index.ts migrate-from-vibora
fi
"""
# Production daemon tasks
[tasks.up]
description = "Build and start production server as daemon"
depends = ["install", "build"]
usage = 'flag "--host" help="Bind to all network interfaces (0.0.0.0)"'
run = """
set -e
FULCRUM_DIR="${FULCRUM_DIR:-$HOME/.fulcrum}"
PID_FILE="$FULCRUM_DIR/fulcrum.pid"
SETTINGS_FILE="$FULCRUM_DIR/settings.json"
# Determine host binding
if [ "$usage_host" = "true" ]; then
HOST="0.0.0.0"
else
HOST="localhost"
fi
# Determine port: env var > settings.json > default 7777
if [ -z "$PORT" ]; then
if [ -f "$SETTINGS_FILE" ] && command -v jq >/dev/null 2>&1; then
# Try nested format first, fall back to flat
PORT=$(jq -r '.server.port // .port // empty' "$SETTINGS_FILE" 2>/dev/null)
fi
PORT="${PORT:-7777}"
fi
# Check if already running
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE")
if kill -0 "$PID" 2>/dev/null; then
echo "Fulcrum already running (PID: $PID)" >&2
exit 1
fi
fi
# Start server in background (server handles migrations on startup)
echo "Starting server..." >&2
mkdir -p "$FULCRUM_DIR"
nohup env NODE_ENV=production PORT="$PORT" HOST="$HOST" bun server/index.ts \
> "$FULCRUM_DIR/server.log" 2>&1 &
PID=$!
# Write PID file
echo "$PID" > "$PID_FILE"
# Verify it started
sleep 1
if ! kill -0 "$PID" 2>/dev/null; then
echo "Server failed to start. Check $FULCRUM_DIR/server.log" >&2
rm -f "$PID_FILE"
exit 1
fi
echo "Fulcrum started on http://localhost:$PORT (PID: $PID)"
"""
[tasks.down]
description = "Stop the daemon server"
run = """
PID_FILE="${FULCRUM_DIR:-$HOME/.fulcrum}/fulcrum.pid"
if [ ! -f "$PID_FILE" ]; then
echo "No PID file found" >&2
exit 1
fi
PID=$(cat "$PID_FILE")
if kill -0 "$PID" 2>/dev/null; then
kill "$PID"
echo "Stopped Fulcrum (PID: $PID)"
else
echo "Process not running"
fi
rm -f "$PID_FILE"
"""
[tasks.restart]
description = "Restart fulcrum systemd service"
depends = ["cli:build"]
run = """
set -e
echo "Linking CLI..." >&2
cd cli && bun link && cd ..
echo "Restarting fulcrum (server handles migrations on startup)..." >&2
systemctl --user restart fulcrum
echo "Done. Checking status..." >&2
systemctl --user status fulcrum --no-pager
"""
# Desktop app tasks (client-only, connects to local or remote Fulcrum server)
[tasks."desktop:setup"]
description = "Install Neutralinojs CLI and dependencies"
run = """
set -e
# Check if neu CLI is installed
if ! command -v neu &> /dev/null; then
echo "Installing Neutralinojs CLI..." >&2
npm install -g @neutralinojs/neu
fi
# Neutralino binaries are vendored in git - just use them
cd desktop
echo "Using vendored Neutralino binaries" >&2
echo "Neutralinojs setup complete"
"""
[tasks."desktop:build"]
description = "Build desktop client app for current platform"
depends = ["desktop:setup", "desktop:bundle"]
run = """
set -e
cd desktop
echo "Building Neutralino app..." >&2
neu build
echo ""
echo "Desktop app built successfully!"
echo "Binaries are in: desktop/dist/"
echo ""
echo "The app will connect to a Fulcrum server running locally or remotely."
"""
[tasks."desktop:run"]
description = "Run desktop app in development mode"
depends = ["desktop:setup"]
run = """
cd desktop
neu run
"""
[tasks."desktop:dev"]
description = "Run desktop app pointing to dev server (port 5173)"
depends = ["desktop:setup"]
run = """
cd desktop
neu run -- --dev
"""
[tasks."desktop:bundle"]
description = "Bundle server and plugin for desktop app"
depends = ["build"]
usage = 'arg "[arch]" help="Architecture: x64 or arm64" default=""'
run = """
set -e
BUNDLE_DIR="desktop/bundle"
rm -rf "$BUNDLE_DIR"
mkdir -p "$BUNDLE_DIR/server" "$BUNDLE_DIR/lib" "$BUNDLE_DIR/drizzle" "$BUNDLE_DIR/dist" "$BUNDLE_DIR/plugin"
# Determine architecture and target
ARCH="${usage_arch}"
if [ -z "$ARCH" ]; then
case "$(uname -m)" in
arm64|aarch64) ARCH="arm64" ;;
*) ARCH="x64" ;;
esac
fi
# Determine target for bun compile
case "$(uname -s)" in
Darwin*) TARGET="bun-darwin-${ARCH}" ;;
Linux*) TARGET="bun-linux-${ARCH}" ;;
*) echo "Unsupported platform" >&2; exit 1 ;;
esac
# Compile server as standalone executable (includes Bun runtime)
echo "Compiling server for ${TARGET}..." >&2
bun build server/index.ts --compile --target="${TARGET}" --outfile="$BUNDLE_DIR/server/fulcrum-server"
chmod +x "$BUNDLE_DIR/server/fulcrum-server"
# Copy native PTY libraries
echo "Copying native PTY libraries..." >&2
cp node_modules/bun-pty/rust-pty/target/release/librust_pty.so "$BUNDLE_DIR/lib/" 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/librust_pty_arm64.so "$BUNDLE_DIR/lib/" 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/librust_pty.dylib "$BUNDLE_DIR/lib/" 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/librust_pty_arm64.dylib "$BUNDLE_DIR/lib/" 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/rust_pty.dll "$BUNDLE_DIR/lib/" 2>/dev/null || true
# Copy migrations (generated during development via: mise run db:generate)
echo "Copying migrations..." >&2
cp -r drizzle/* "$BUNDLE_DIR/drizzle/"
# Copy frontend build
echo "Copying frontend build..." >&2
cp -r dist/* "$BUNDLE_DIR/dist/"
# Copy Claude plugin (including hidden .claude-plugin directory)
echo "Copying Claude plugin..." >&2
cp -r plugins/fulcrum/. "$BUNDLE_DIR/plugin/"
# Copy package.json for version info (desktop app derives schema version from major version)
echo "Copying package.json..." >&2
cp package.json "$BUNDLE_DIR/"
echo "Desktop bundle created at $BUNDLE_DIR (standalone executable, no Bun required)"
"""
[tasks."desktop:bundle:debug"]
description = "Bundle server and plugin for desktop app with debug logging"
depends = ["build:debug"]
usage = 'arg "[arch]" help="Architecture: x64 or arm64" default=""'
run = """
set -e
BUNDLE_DIR="desktop/bundle"
rm -rf "$BUNDLE_DIR"
mkdir -p "$BUNDLE_DIR/server" "$BUNDLE_DIR/lib" "$BUNDLE_DIR/drizzle" "$BUNDLE_DIR/dist" "$BUNDLE_DIR/plugin"
# Determine architecture and target
ARCH="${usage_arch}"
if [ -z "$ARCH" ]; then
case "$(uname -m)" in
arm64|aarch64) ARCH="arm64" ;;
*) ARCH="x64" ;;
esac
fi
# Determine target for bun compile
case "$(uname -s)" in
Darwin*) TARGET="bun-darwin-${ARCH}" ;;
Linux*) TARGET="bun-linux-${ARCH}" ;;
*) echo "Unsupported platform" >&2; exit 1 ;;
esac
# Compile server as standalone executable (includes Bun runtime)
echo "Compiling server for ${TARGET} (DEBUG)..." >&2
bun build server/index.ts --compile --target="${TARGET}" --outfile="$BUNDLE_DIR/server/fulcrum-server"
chmod +x "$BUNDLE_DIR/server/fulcrum-server"
# Copy native PTY libraries
echo "Copying native PTY libraries..." >&2
cp node_modules/bun-pty/rust-pty/target/release/librust_pty.so "$BUNDLE_DIR/lib/" 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/librust_pty_arm64.so "$BUNDLE_DIR/lib/" 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/librust_pty.dylib "$BUNDLE_DIR/lib/" 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/librust_pty_arm64.dylib "$BUNDLE_DIR/lib/" 2>/dev/null || true
cp node_modules/bun-pty/rust-pty/target/release/rust_pty.dll "$BUNDLE_DIR/lib/" 2>/dev/null || true
# Copy migrations (generated during development via: mise run db:generate)
echo "Copying migrations..." >&2
cp -r drizzle/* "$BUNDLE_DIR/drizzle/"
# Copy frontend build (with debug logging)
echo "Copying frontend build (DEBUG)..." >&2
cp -r dist/* "$BUNDLE_DIR/dist/"
# Copy Claude plugin (including hidden .claude-plugin directory)
echo "Copying Claude plugin..." >&2
cp -r plugins/fulcrum/. "$BUNDLE_DIR/plugin/"
# Copy package.json for version info (desktop app derives schema version from major version)
echo "Copying package.json..." >&2
cp package.json "$BUNDLE_DIR/"
echo "Desktop DEBUG bundle created at $BUNDLE_DIR"
"""
[tasks."desktop:build:debug"]
description = "Build desktop client app with debug logging"
depends = ["desktop:setup", "desktop:bundle:debug"]
run = """
set -e
cd desktop
echo "Building Neutralino app (DEBUG)..." >&2
neu build
echo ""
echo "Desktop DEBUG app built successfully!"
echo "Binaries are in: desktop/dist/"
"""
[tasks."desktop:clean"]
description = "Clean desktop build artifacts"
run = """
rm -rf desktop/dist
rm -rf desktop/bin
rm -rf desktop/bundle
echo "Desktop build artifacts cleaned"
"""
[tasks."desktop:clean-packages"]
description = "Remove old DMG and AppImage packages"
run = """
rm -f desktop/dist/*.dmg desktop/dist/*.AppImage
echo "Removed old packages from desktop/dist/"
"""
[tasks."desktop:package-appimage"]
description = "Package desktop app as AppImage (Linux)"
depends = ["desktop:build", "desktop:clean-packages"]
usage = 'arg "[arch]" help="Architecture: x64 or arm64" default="x64"'
run = """
./desktop/scripts/package-appimage.sh "${usage_arch}"
"""
[tasks."desktop:package-dmg"]
description = "Package desktop app as DMG (macOS)"
depends = ["desktop:build", "desktop:clean-packages"]
usage = 'arg "[arch]" help="Architecture: x64 or arm64" default=""'
run = """
./desktop/scripts/package-dmg.sh "${usage_arch}"
"""
[tasks."desktop:package-dmg:debug"]
description = "Package desktop app as DMG with debug logging (macOS)"
depends = ["desktop:build:debug", "desktop:clean-packages"]
usage = 'arg "[arch]" help="Architecture: x64 or arm64" default=""'
run = """
./desktop/scripts/package-dmg.sh "${usage_arch}"
"""
[tasks."desktop:package"]
description = "Package desktop app for current platform"
depends = ["desktop:build", "desktop:clean-packages"]
run = """
set -e
case "$(uname -s)" in
Linux*)
if [ "$(uname -m)" = "aarch64" ]; then
./desktop/scripts/package-appimage.sh arm64
else
./desktop/scripts/package-appimage.sh x64
fi
;;
Darwin*)
if [ "$(uname -m)" = "arm64" ]; then
./desktop/scripts/package-dmg.sh arm64
else
./desktop/scripts/package-dmg.sh x64
fi
;;
*)
echo "Packaging not supported on this platform"
exit 1
;;
esac
"""
[tasks."desktop:manifest"]
description = "Generate update manifest.json for testing"
run = """
set -e
VERSION=$(jq -r '.version' package.json)
REPO="knowsuchagency/fulcrum"
mkdir -p desktop/dist
cat > desktop/dist/manifest.json << EOF
{
"applicationId": "io.fulcrum.desktop",
"version": "${VERSION}",
"platforms": {
"darwin-arm64": {
"url": "https://github.com/${REPO}/releases/download/v${VERSION}/Fulcrum-${VERSION}-macos-arm64.dmg"
},
"linux-x64": {
"url": "https://github.com/${REPO}/releases/download/v${VERSION}/Fulcrum-${VERSION}-linux-x64.AppImage"
}
}
}
EOF
echo "Generated manifest.json for version $VERSION"
cat desktop/dist/manifest.json
"""
[tasks."opencode:install"]
description = "Install OpenCode plugin from source"
run = """
OPENCODE_PLUGIN_DIR="$HOME/.config/opencode/plugin"
mkdir -p "$OPENCODE_PLUGIN_DIR"
cp plugins/fulcrum-opencode/index.ts "$OPENCODE_PLUGIN_DIR/fulcrum.ts"
echo "Installed OpenCode plugin at $OPENCODE_PLUGIN_DIR/fulcrum.ts"
echo "Restart OpenCode to load the updated plugin."
"""
[tasks."desktop:release"]
description = "Build all desktop packages for current platform"
depends = ["check:version", "desktop:build"]
run = """
set -e
case "$(uname -s)" in
Darwin*)
echo "Building macOS package..."
./desktop/scripts/package-dmg.sh arm64
;;
Linux*)
echo "Building Linux package..."
./desktop/scripts/package-appimage.sh x64
;;
esac
mise run desktop:manifest
echo "Desktop release packages ready in desktop/dist/"
"""
# Worker tasks
[tasks."worker:deploy"]
description = "Deploy fulcrum-utils Cloudflare worker"
dir = "fulcrum-utils"
run = "bun run deploy"