-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.sh
More file actions
1128 lines (1055 loc) · 43.2 KB
/
run.sh
File metadata and controls
1128 lines (1055 loc) · 43.2 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
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
if [ ! -f "venv/bin/python" ]; then
echo "Virtual environment not found. Please run ./install.sh first."
read -p "Press Enter to exit..."
exit 1
fi
if [ $# -eq 0 ]; then
show_menu
else
venv/bin/python cli.py "$@"
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo ""
echo "Command failed with exit code $exit_code"
read -p "Press Enter to continue..."
fi
exit $exit_code
fi
show_menu() {
while true; do
clear
echo ""
echo "================================================================================"
echo " ProspectAI - Intelligent Job Automation System v2.0"
echo "================================================================================"
echo ""
echo " \033[32mMAIN MENU\033[0m"
echo ""
echo "[1] Quick Start - Complete setup + run first campaign"
echo "[2] Guided Setup - Step-by-step configuration wizard"
echo "[3] Run Campaign - Full workflow: discovery + emails + analytics"
echo "[4] Discovery Only - Find companies and prospects (advanced)"
echo "[5] Email Generation - Create personalized emails for recent prospects"
echo "[6] Send Emails - Send the most recent generated emails"
echo ""
echo "[7] Status Dashboard - Show current workflow status and statistics"
echo "[8] Validate Config - Check your API configuration and connections"
echo "[9] Setup Dashboard - Create/update Notion dashboard"
echo ""
echo "\033[36m[A] Advanced Options\033[0m - Custom campaigns, specific company processing"
echo "\033[33m[M] Maintenance Menu\033[0m - System health, repairs, configuration management"
echo "\033[35m[H] Help and Info\033[0m - Commands, system info, documentation"
echo ""
echo "\033[31m[0] Exit\033[0m"
echo ""
echo "================================================================================"
read -p "Enter your choice (0-9, A, M, H): " choice
echo ""
case $choice in
1)
echo "\033[32mRunning Quick Start Campaign...\033[0m"
echo "This will discover 5 companies, find prospects, and generate sample emails"
venv/bin/python cli.py quick-start --limit 5
echo ""
read -p "Press Enter to continue..."
;;
2)
echo "\033[33mStarting Guided Setup Wizard...\033[0m"
echo "This will help you configure your API keys and settings"
venv/bin/python cli.py validate-config
if [ $? -eq 0 ]; then
echo "Configuration looks good! Setting up dashboard..."
venv/bin/python cli.py setup-dashboard
fi
echo ""
read -p "Press Enter to continue..."
;;
3)
echo "\033[33mRunning Full Campaign Workflow...\033[0m"
read -p "Enter number of companies to process (default 10): " limit
if [ -z "$limit" ]; then limit=10; fi
echo "Processing $limit companies with full workflow..."
venv/bin/python cli.py run-campaign --limit $limit
echo ""
read -p "Press Enter to continue..."
;;
4)
echo "\033[36mRunning Discovery Pipeline...\033[0m"
read -p "Enter number of companies to discover (default 20): " limit
if [ -z "$limit" ]; then limit=20; fi
echo "Discovering $limit companies and extracting team information..."
venv/bin/python cli.py discover --limit $limit
echo ""
read -p "Press Enter to continue..."
;;
5)
echo "\033[35mGenerating Personalized Emails...\033[0m"
read -p "Enter number of emails to generate (default 10): " limit
if [ -z "$limit" ]; then limit=10; fi
echo "Generating $limit personalized emails for recent prospects..."
venv/bin/python cli.py generate-emails-recent --limit $limit
echo ""
read -p "Press Enter to continue..."
;;
6)
echo "\033[35mSending Recent Emails...\033[0m"
read -p "Enter number of emails to send (default 5): " limit
if [ -z "$limit" ]; then limit=5; fi
read -p "Enter delay between emails in seconds (default 30): " delay
if [ -z "$delay" ]; then delay=30; fi
echo "Sending $limit emails with $delay second delay..."
venv/bin/python cli.py send-emails-recent --limit $limit --delay $delay
echo ""
read -p "Press Enter to continue..."
;;
7)
echo "\033[36mChecking System Status...\033[0m"
venv/bin/python cli.py status
echo ""
read -p "Press Enter to continue..."
;;
8)
echo "\033[36mChecking Campaign Progress...\033[0m"
venv/bin/python cli.py campaign-status
echo ""
read -p "Press Enter to continue..."
;;
9)
echo "\033[36mGenerating Analytics Report...\033[0m"
echo "[1] Daily Report"
echo "[2] Weekly Report"
echo "[3] Monthly Report"
read -p "Select report period (1-3): " period_choice
case $period_choice in
1) period="daily" ;;
2) period="weekly" ;;
3) period="monthly" ;;
*) period="daily" ;;
esac
venv/bin/python cli.py analytics-report --period $period
echo ""
read -p "Press Enter to continue..."
;;
10)
echo "\033[36mManaging Email Queue...\033[0m"
venv/bin/python cli.py email-queue
echo ""
read -p "Press Enter to continue..."
;;
11)
echo "\033[35mValidating Configuration...\033[0m"
echo "Checking API keys and connections..."
venv/bin/python cli.py validate-config
echo ""
read -p "Press Enter to continue..."
;;
12)
echo "\033[35mSetting up Notion Dashboard...\033[0m"
echo "Creating databases and dashboard structure..."
venv/bin/python cli.py setup-dashboard
echo ""
read -p "Press Enter to continue..."
;;
13)
echo "\033[35mConfiguring Sender Profile...\033[0m"
venv/bin/python cli.py profile-setup
echo ""
read -p "Press Enter to continue..."
;;
14)
echo "\033[35mConfiguring AI Providers...\033[0m"
venv/bin/python cli.py configure-ai
echo ""
read -p "Press Enter to continue..."
;;
15)
custom_campaign
;;
16)
process_company
;;
17)
show_help
;;
18)
system_info
;;
19)
installation_check
;;
20)
repair_installation
;;
21)
config_management
;;
22)
system_health
;;
23)
update_check
;;
24)
debug_mode
;;
25)
batch_operations
;;
0)
echo "\033[32mGoodbye! Thanks for using ProspectAI!\033[0m"
exit 0
;;
*)
echo "\033[31mInvalid choice. Please enter a number between 0 and 25.\033[0m"
echo ""
read -p "Press Enter to continue..."
;;
esac
done
}
custom_campaign() {
clear
echo ""
echo "================================================================================"
echo " CUSTOM CAMPAIGN CONFIGURATION"
echo "================================================================================"
echo ""
read -p "Enter campaign name (default: Custom Campaign): " campaign_name
if [ -z "$campaign_name" ]; then campaign_name="Custom Campaign"; fi
read -p "Enter number of companies to process (default: 10): " company_limit
if [ -z "$company_limit" ]; then company_limit=10; fi
echo ""
echo "Campaign Options:"
echo "[1] Discovery only"
echo "[2] Discovery + Email Generation"
echo "[3] Full workflow (Discovery + Emails + Sending)"
read -p "Select workflow type (1-3): " workflow_choice
echo ""
echo "\033[33mRunning Custom Campaign: $campaign_name\033[0m"
echo "Companies to process: $company_limit"
case $workflow_choice in
1)
echo "Workflow: Discovery only"
venv/bin/python cli.py discover --limit $company_limit --campaign-name "$campaign_name"
;;
2)
echo "Workflow: Discovery + Email Generation"
venv/bin/python cli.py run-campaign --limit $company_limit --campaign-name "$campaign_name" --no-send
;;
*)
echo "Workflow: Full workflow with email sending"
read -p "Enter delay between emails (seconds, default: 60): " email_delay
if [ -z "$email_delay" ]; then email_delay=60; fi
venv/bin/python cli.py run-campaign --limit $company_limit --campaign-name "$campaign_name" --delay $email_delay
;;
esac
echo ""
echo "\033[32mCustom campaign completed!\033[0m"
echo ""
read -p "Press Enter to return to main menu..."
}
process_company() {
clear
echo ""
echo "================================================================================"
echo " PROCESS SPECIFIC COMPANY"
echo "================================================================================"
echo ""
read -p "Enter company name to process: " company_name
if [ -z "$company_name" ]; then
echo "\033[31mCompany name cannot be empty!\033[0m"
read -p "Press Enter to continue..."
return
fi
read -p "Enter company domain (optional): " company_domain
echo ""
echo "\033[33mProcessing company: $company_name\033[0m"
if [ -n "$company_domain" ]; then
echo "Domain: $company_domain"
venv/bin/python cli.py process-company "$company_name" --domain "$company_domain"
else
venv/bin/python cli.py process-company "$company_name"
fi
echo ""
echo "\033[32mCompany processing completed!\033[0m"
echo ""
read -p "Press Enter to return to main menu..."
}
installation_check() {
clear
echo ""
echo "================================================================================"
echo " INSTALLATION STATUS DIAGNOSTICS"
echo "================================================================================"
echo ""
echo "\033[96mRunning comprehensive installation check...\033[0m"
echo ""
echo "\033[36m1. Python Installation Check\033[0m"
echo "----------------------------------------"
if [ -f "venv/bin/python" ]; then
echo "\033[32mOK - Virtual environment found\033[0m"
echo "Path: $(pwd)/venv/bin/python"
echo "Version: $(venv/bin/python --version)"
echo ""
echo "\033[36mChecking Python packages...\033[0m"
if venv/bin/python -m pip list --local 2>/dev/null | grep -i "click\|rich" >/dev/null; then
echo "\033[32mOK - Core packages installed\033[0m"
else
echo "\033[33mWARNING - Some core packages may be missing\033[0m"
fi
else
echo "\033[31mFAILED - Virtual environment not found\033[0m"
echo "Expected path: $(pwd)/venv/bin/python"
echo "\033[33mRecovery: Run ./install.sh to create virtual environment\033[0m"
fi
echo ""
echo "\033[36m2. Configuration Check\033[0m"
echo "----------------------------------------"
if [ -f ".env" ]; then
echo "\033[32mOK - Configuration file found\033[0m"
echo "Path: $(pwd)/.env"
echo ""
echo "\033[36mChecking required API keys...\033[0m"
if grep -q "NOTION_TOKEN" .env 2>/dev/null; then
echo "\033[32mOK - Notion token configured\033[0m"
else
echo "\033[31mMISSING - Notion token not found\033[0m"
fi
if grep -q "HUNTER_API_KEY" .env 2>/dev/null; then
echo "\033[32mOK - Hunter API key configured\033[0m"
else
echo "\033[31mMISSING - Hunter API key not found\033[0m"
fi
else
echo "\033[31mFAILED - Configuration file not found\033[0m"
echo "Expected path: $(pwd)/.env"
echo "\033[33mRecovery: Run setup or validate-config command\033[0m"
fi
echo ""
echo "\033[36m3. Dependencies & CLI Check\033[0m"
echo "----------------------------------------"
if [ -f "requirements.txt" ]; then
echo "\033[32mOK - Requirements file found\033[0m"
else
echo "\033[31mFAILED - Requirements file not found\033[0m"
fi
if [ -f "venv/bin/python" ]; then
if [ -f "cli.py" ]; then
echo "\033[32mOK - CLI script found\033[0m"
echo ""
echo "\033[36mTesting CLI help command...\033[0m"
if venv/bin/python cli.py --help >/dev/null 2>&1; then
echo "\033[32mOK - CLI is functional\033[0m"
else
echo "\033[31mFAILED - CLI command failed\033[0m"
fi
else
echo "\033[31mFAILED - CLI script not found\033[0m"
fi
else
echo "\033[33mSKIPPED - Cannot test CLI without virtual environment\033[0m"
fi
echo ""
echo "================================================================================"
echo "\033[96mInstallation Check Complete\033[0m"
echo ""
echo "\033[36mNext Steps:\033[0m"
echo "- If any components failed, use option [20] Repair Installation"
echo "- Run validate-config to test API connectivity"
echo "================================================================================"
echo ""
read -p "Press Enter to return to main menu..."
}
repair_installation() {
clear
echo ""
echo "================================================================================"
echo " AUTOMATED INSTALLATION REPAIR"
echo "================================================================================"
echo ""
echo "\033[96mThis will attempt to fix common installation issues...\033[0m"
echo ""
echo "\033[36mStep 1: Checking virtual environment...\033[0m"
if [ ! -f "venv/bin/python" ]; then
echo "\033[33mVirtual environment missing. Attempting to recreate...\033[0m"
if python3 -m venv venv; then
echo "\033[32mOK - Virtual environment created\033[0m"
else
echo "\033[31mFAILED - Could not create virtual environment\033[0m"
echo "Please run ./install.sh manually"
read -p "Press Enter to return to main menu..."
return
fi
else
echo "\033[32mOK - Virtual environment exists\033[0m"
fi
echo ""
echo "\033[36mStep 2: Updating pip and installing/upgrading dependencies...\033[0m"
venv/bin/python -m pip install --upgrade pip
if [ -f "requirements.txt" ]; then
echo "Installing requirements..."
if venv/bin/python -m pip install -r requirements.txt --upgrade; then
echo "\033[32mOK - Dependencies installed/updated\033[0m"
else
echo "\033[33mWARNING - Some dependencies may have failed to install\033[0m"
fi
else
echo "\033[33mWARNING - requirements.txt not found\033[0m"
fi
echo ""
echo "\033[36mStep 3: Checking configuration...\033[0m"
if [ ! -f ".env" ]; then
echo "\033[33mConfiguration file missing. Creating template...\033[0m"
cat > .env << EOF
# ProspectAI Configuration File
# Required API Keys:
NOTION_TOKEN=
HUNTER_API_KEY=
OPENAI_API_KEY=
# Optional Email Configuration:
RESEND_API_KEY=
SENDER_EMAIL=
SENDER_NAME=
EOF
echo "\033[33mCreated .env template. Please add your API keys.\033[0m"
else
echo "\033[32mOK - Configuration file exists\033[0m"
fi
echo ""
echo "\033[36mStep 4: Testing CLI functionality...\033[0m"
if venv/bin/python cli.py --help >/dev/null 2>&1; then
echo "\033[32mOK - CLI is working\033[0m"
else
echo "\033[33mWARNING - CLI test failed. May need configuration.\033[0m"
fi
echo ""
echo "================================================================================"
echo "\033[96mRepair Process Complete\033[0m"
echo ""
echo "\033[36mRecommended Next Steps:\033[0m"
echo "1. Run Installation Check [19] to verify repairs"
echo "2. Configure API keys if .env was recreated"
echo "3. Run validate-config to test connections"
echo "4. Use setup-dashboard to initialize workspace"
echo "================================================================================"
echo ""
read -p "Press Enter to return to main menu..."
}
show_help() {
clear
echo ""
echo "================================================================================"
echo " PROSPECTAI COMMAND REFERENCE"
echo "================================================================================"
echo ""
echo "\033[32m>> QUICK START COMMANDS\033[0m"
echo " quick-start - Complete setup + first campaign (5 companies)"
echo " validate-config - Check API configuration and connections"
echo " setup-dashboard - Create/update Notion dashboard"
echo ""
echo "\033[33m>> MAIN WORKFLOW COMMANDS\033[0m"
echo " run-campaign - Full workflow: discovery + emails + analytics"
echo " discover - Discovery only (find companies and prospects)"
echo " generate-emails-recent - Generate emails for recent prospects"
echo " send-emails-recent - Send the most recent generated emails"
echo ""
echo "\033[36m>> MONITORING COMMANDS\033[0m"
echo " status - Show workflow status and statistics"
echo " campaign-status - Show current campaign progress"
echo " analytics-report - View analytics and performance stats"
echo " email-queue - Manage email queue and delivery status"
echo ""
echo "\033[35m>> CONFIGURATION COMMANDS\033[0m"
echo " configure-ai - Configure AI providers (OpenAI, Anthropic, etc.)"
echo " profile-setup - Setup sender profile for personalization"
echo ""
echo "\033[37m>> ADVANCED COMMANDS\033[0m"
echo " process-company - Process a specific company by name"
echo " send-emails - Send emails to specific prospects"
echo " analyze-products - Run AI analysis on company products"
echo " daily-summary - Create daily analytics summary"
echo ""
echo "\033[33m>> USAGE EXAMPLES\033[0m"
echo " ./run.sh - Show interactive menu (current mode)"
echo " ./run.sh quick-start - Run quick start campaign"
echo " ./run.sh run-campaign --limit 5"
echo " ./run.sh discover --limit 20 --campaign-name \"My Campaign\""
echo " ./run.sh generate-emails-recent --limit 10"
echo " ./run.sh send-emails-recent --limit 5 --delay 60"
echo " ./run.sh process-company \"TechCorp\" --domain \"techcorp.com\""
echo ""
echo "\033[36m>> PARAMETER OPTIONS\033[0m"
echo " --limit N - Limit number of companies/prospects to process"
echo " --campaign-name \"Name\" - Set custom campaign name for tracking"
echo " --delay N - Set delay between email sends (seconds)"
echo " --dry-run - Run in simulation mode without making changes"
echo " --verbose - Enable detailed logging output"
echo ""
echo "\033[33m>> GETTING HELP\033[0m"
echo " ./run.sh [command] --help - Get detailed help for specific command"
echo " Online Documentation: - Check GitHub repository for full docs"
echo " Configuration Guide: - See README.md for API key setup"
echo ""
echo "================================================================================"
read -p "Press Enter to return to main menu..."
}
system_info() {
clear
echo ""
echo "================================================================================"
echo " SYSTEM INFORMATION"
echo "================================================================================"
echo ""
echo "\033[36mProspectAI System Status\033[0m"
echo ""
echo "Python Environment:"
if [ -f "venv/bin/python" ]; then
echo "\033[32mOK - Virtual environment: Active\033[0m"
venv/bin/python --version
else
echo "\033[31mMISSING - Virtual environment: Not found\033[0m"
fi
echo ""
echo "Configuration Status:"
if [ -f ".env" ]; then
echo "\033[32mOK - Configuration file: Found\033[0m"
else
echo "\033[31mMISSING - Configuration file: Not found\033[0m"
fi
echo ""
echo "Available CLI Commands:"
if [ -f "venv/bin/python" ]; then
venv/bin/python cli.py --help
else
echo "Cannot display commands - virtual environment not found"
fi
echo ""
echo "\033[36mQuick Validation:\033[0m"
if [ -f "venv/bin/python" ]; then
venv/bin/python cli.py validate-config
else
echo "Cannot validate - virtual environment not found"
fi
echo ""
read -p "Press Enter to return to main menu..."
}
config_management() {
clear
echo ""
echo "================================================================================"
echo " CONFIGURATION MANAGEMENT"
echo "================================================================================"
echo ""
echo "[1] Backup Configuration - Create backup of current .env file"
echo "[2] Restore Configuration - Restore from backup file"
echo "[3] View Configuration - Display current configuration (masked)"
echo "[4] Reset Configuration - Create fresh .env template"
echo "[5] Export Configuration - Export config template for transfer"
echo "[6] Configuration History - View backup history"
echo ""
echo "[0] Return to Main Menu"
echo ""
echo "================================================================================"
read -p "Select configuration option (0-6): " config_choice
echo ""
case $config_choice in
1)
echo "\033[36mCreating configuration backup...\033[0m"
if [ -f ".env" ]; then
backup_name=".env.backup.$(date +%Y%m%d_%H%M%S)"
if cp ".env" "$backup_name"; then
echo "\033[32mOK - Backup created: $backup_name\033[0m"
else
echo "\033[31mFAILED - Could not create backup\033[0m"
fi
else
echo "\033[33mWARNING - No .env file found to backup\033[0m"
fi
;;
2)
echo "\033[36mAvailable backup files:\033[0m"
ls .env.backup.* 2>/dev/null
if [ $? -ne 0 ]; then
echo "\033[33mNo backup files found\033[0m"
else
echo ""
read -p "Enter backup filename to restore: " backup_file
if [ -f "$backup_file" ]; then
if cp "$backup_file" ".env"; then
echo "\033[32mOK - Configuration restored from $backup_file\033[0m"
else
echo "\033[31mFAILED - Could not restore configuration\033[0m"
fi
else
echo "\033[31mFAILED - Backup file not found\033[0m"
fi
fi
;;
3)
echo "\033[36mCurrent configuration (API keys masked):\033[0m"
if [ -f ".env" ]; then
echo ""
while IFS='=' read -r key value; do
if [ -n "$key" ] && [[ ! "$key" =~ ^# ]]; then
if [ -n "$value" ]; then
echo "$key=***MASKED***"
else
echo "$key="
fi
else
echo "$key"
fi
done < .env
else
echo "\033[33mNo .env file found\033[0m"
fi
;;
4)
echo "\033[36mCreating fresh configuration template...\033[0m"
if [ -f ".env" ]; then
echo "\033[33mExisting .env file will be overwritten!\033[0m"
read -p "Continue? (y/N): " confirm
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
echo "Operation cancelled."
read -p "Press Enter to continue..."
return
fi
fi
cat > .env << EOF
# ProspectAI Configuration File
# Generated on $(date)
# Required API Keys:
NOTION_TOKEN=
HUNTER_API_KEY=
OPENAI_API_KEY=
# Optional Email Configuration:
RESEND_API_KEY=
SENDER_EMAIL=
SENDER_NAME=
# Optional AI Provider Configuration:
ANTHROPIC_API_KEY=
GOOGLE_API_KEY=
DEEPSEEK_API_KEY=
EOF
echo "\033[32mOK - Fresh configuration template created\033[0m"
;;
5)
echo "\033[36mExporting configuration template...\033[0m"
if [ -f ".env" ]; then
{
echo "# ProspectAI Configuration Template"
echo "# Exported on $(date)"
echo ""
while IFS='=' read -r key value; do
if [ -n "$key" ] && [[ ! "$key" =~ ^# ]]; then
echo "$key="
else
echo "$key"
fi
done < .env
} > .env.template
echo "\033[32mOK - Configuration template exported to .env.template\033[0m"
else
echo "\033[33mNo .env file found to export\033[0m"
fi
;;
6)
echo "\033[36mConfiguration backup history:\033[0m"
echo ""
ls -lt .env.backup.* 2>/dev/null
if [ $? -ne 0 ]; then
echo "\033[33mNo backup files found\033[0m"
fi
;;
0)
return
;;
*)
echo "\033[31mInvalid choice. Please select 0-6.\033[0m"
;;
esac
echo ""
read -p "Press Enter to continue..."
config_management
}
system_health() {
clear
echo ""
echo "================================================================================"
echo " SYSTEM HEALTH & PERFORMANCE MONITORING"
echo "================================================================================"
echo ""
echo "\033[96mChecking system health and performance...\033[0m"
echo ""
echo "\033[36m1. Virtual Environment Health\033[0m"
echo "----------------------------------------"
if [ -f "venv/bin/python" ]; then
echo "\033[32mOK - Virtual environment active\033[0m"
echo ""
echo "\033[36mPython environment details:\033[0m"
venv/bin/python -c "import sys; print(f'Python: {sys.version.split()[0]}'); print(f'Platform: {sys.platform}')"
echo ""
echo "\033[36mPackage health check:\033[0m"
if venv/bin/python -m pip check >/dev/null 2>&1; then
echo "\033[32mOK - No dependency conflicts detected\033[0m"
else
echo "\033[33mWARNING - Some dependency conflicts detected\033[0m"
fi
else
echo "\033[31mFAILED - Virtual environment not found\033[0m"
fi
echo ""
echo "\033[36m2. Disk Space Usage\033[0m"
echo "----------------------------------------"
echo "Project directory size:"
du -sh . 2>/dev/null || echo "Could not determine directory size"
if [ -d "venv" ]; then
echo ""
echo "Virtual environment size:"
du -sh venv 2>/dev/null || echo "Could not determine venv size"
fi
echo ""
echo "Available disk space:"
df -h . 2>/dev/null || echo "Could not determine disk space"
echo ""
echo "\033[36m3. Network Connectivity\033[0m"
echo "----------------------------------------"
echo "Testing API endpoints..."
echo "\033[36mTesting api.notion.com...\033[0m"
if ping -c 1 api.notion.com >/dev/null 2>&1; then
echo "\033[32mOK - Notion API reachable\033[0m"
else
echo "\033[33mWARNING - Notion API unreachable\033[0m"
fi
echo ""
echo "\033[36m4. Configuration Health\033[0m"
echo "----------------------------------------"
if [ -f ".env" ]; then
echo "\033[32mOK - Configuration file present\033[0m"
echo ""
echo "\033[36mRunning configuration validation...\033[0m"
if [ -f "venv/bin/python" ]; then
if venv/bin/python cli.py validate-config >/dev/null 2>&1; then
echo "\033[32mOK - Configuration validation passed\033[0m"
else
echo "\033[33mWARNING - Configuration validation failed\033[0m"
fi
else
echo "\033[33mSKIPPED - No virtual environment to test with\033[0m"
fi
else
echo "\033[31mFAILED - Configuration file missing\033[0m"
fi
echo ""
echo "================================================================================"
echo "\033[96mSystem Health Check Complete\033[0m"
echo ""
echo "\033[36mRecommendations:\033[0m"
echo "- Monitor virtual environment for package conflicts"
echo "- Ensure adequate disk space for operation"
echo "- Check network connectivity if API calls fail"
echo "- Validate configuration regularly"
echo "================================================================================"
echo ""
read -p "Press Enter to return to main menu..."
}
update_check() {
clear
echo ""
echo "================================================================================"
echo " UPDATE CHECK & MAINTENANCE"
echo "================================================================================"
echo ""
echo "\033[96mChecking for updates and maintenance notifications...\033[0m"
echo ""
echo "\033[36m1. Python Package Updates\033[0m"
echo "----------------------------------------"
if [ -f "venv/bin/python" ]; then
echo "\033[36mChecking for outdated packages...\033[0m"
venv/bin/python -m pip list --outdated 2>/dev/null
if [ $? -eq 0 ]; then
echo ""
echo "\033[36mTo update packages, use: venv/bin/python -m pip install --upgrade [package]\033[0m"
else
echo "\033[32mAll packages appear to be up to date\033[0m"
fi
else
echo "\033[33mSKIPPED - No virtual environment found\033[0m"
fi
echo ""
echo "\033[36m2. Configuration Status\033[0m"
echo "----------------------------------------"
if [ -f ".env" ]; then
echo "\033[32mConfiguration file present\033[0m"
echo ""
echo "\033[36mChecking configuration validation...\033[0m"
if [ -f "venv/bin/python" ]; then
if venv/bin/python cli.py validate-config >/dev/null 2>&1; then
echo "\033[32mConfiguration validation passed\033[0m"
else
echo "\033[33mConfiguration validation failed - may need updates\033[0m"
fi
fi
else
echo "\033[33mNo configuration file found\033[0m"
fi
echo ""
echo "\033[36m3. Repository Status\033[0m"
echo "----------------------------------------"
echo "\033[36mChecking git status...\033[0m"
if git status >/dev/null 2>&1; then
echo "\033[32mGit repository detected\033[0m"
else
echo "\033[33mNot a git repository or git not available\033[0m"
fi
echo ""
echo "\033[36m4. Maintenance Recommendations\033[0m"
echo "----------------------------------------"
echo "\033[36mBased on system analysis:\033[0m"
echo ""
echo "- Run installation check [19] monthly"
echo "- Backup configuration [21] before major changes"
echo "- Monitor system health [22] regularly"
echo "- Update dependencies periodically"
echo "- Review API key rotation schedule"
echo ""
echo "================================================================================"
echo "\033[96mUpdate Check Complete\033[0m"
echo "================================================================================"
echo ""
read -p "Press Enter to return to main menu..."
}
debug_mode() {
clear
echo ""
echo "================================================================================"
echo " ADVANCED DEBUGGING & LOGGING TOOLS"
echo "================================================================================"
echo ""
echo "[1] Enable Debug Logging - Turn on verbose logging for next operation"
echo "[2] View Recent Logs - Display recent application logs"
echo "[3] Test CLI Commands - Interactive CLI command testing"
echo "[4] Environment Dump - Export complete environment information"
echo "[5] Network Diagnostics - Advanced network and API testing"
echo "[6] Clear Debug Data - Clean up debug files and logs"
echo ""
echo "[0] Return to Main Menu"
echo ""
echo "================================================================================"
read -p "Select debug option (0-6): " debug_choice
echo ""
case $debug_choice in
1)
echo "\033[36mEnabling debug logging for next operation...\033[0m"
export DEBUG_MODE=1
echo "\033[32mDEBUG MODE ENABLED\033[0m"
echo ""
echo "Debug logging will be active for the next CLI command you run."
echo "To disable, restart the script."
;;
2)
echo "\033[36mRecent application logs:\033[0m"
echo ""
if [ -d "logs" ]; then
echo "\033[36mLast few lines from recent log files:\033[0m"
for logfile in $(ls -t logs/*.log 2>/dev/null | head -1); do
if [ -f "$logfile" ]; then
echo ""
echo "\033[33m--- $logfile ---\033[0m"
tail -10 "$logfile" 2>/dev/null
break
fi
done
else
echo "\033[33mNo logs directory found\033[0m"
fi
;;
3)
echo "\033[36mInteractive CLI Command Testing\033[0m"
echo ""
echo "Type CLI commands to test (without './run.sh' prefix)"
echo "Examples: status, validate-config, --help"
echo "Type 'exit' to return to debug menu"
echo ""
while true; do
read -p "CLI> " test_cmd
if [ "$test_cmd" = "exit" ]; then
break
fi
if [ -n "$test_cmd" ]; then
echo "\033[36mExecuting: venv/bin/python cli.py $test_cmd\033[0m"
if [ -f "venv/bin/python" ]; then
venv/bin/python cli.py $test_cmd
echo ""
echo "\033[36mCommand completed with exit code: $?\033[0m"
else
echo "\033[31mERROR: Virtual environment not found\033[0m"
fi
echo ""
fi
done
;;
4)
echo "\033[36mGenerating environment dump...\033[0m"
dump_file="debug_environment_$(date +%Y%m%d_%H%M%S).txt"
{
echo "ProspectAI Environment Debug Dump"
echo "Generated: $(date)"
echo "================================"
echo ""
echo "PYTHON ENVIRONMENT:"
if [ -f "venv/bin/python" ]; then
venv/bin/python --version
echo ""
echo "INSTALLED PACKAGES:"
venv/bin/python -m pip list
else
echo "Virtual environment not found"
fi
echo ""
echo "CONFIGURATION STATUS:"
if [ -f ".env" ]; then
echo ".env file exists"
else
echo ".env file missing"
fi
} > "$dump_file"
echo "\033[32mEnvironment dump saved to: $dump_file\033[0m"
;;
5)
echo "\033[36mNetwork & API Diagnostics\033[0m"
echo ""
echo "\033[36mTesting network connectivity...\033[0m"
if ping -c 1 api.notion.com >/dev/null 2>&1; then
echo "\033[32mNotion API reachable\033[0m"
else
echo "\033[33mNotion API unreachable\033[0m"
fi
;;
6)
echo "\033[36mCleaning up debug data...\033[0m"
if ls debug_environment_*.txt >/dev/null 2>&1; then
rm debug_environment_*.txt
echo "\033[32mDebug dump files cleared\033[0m"