-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
1288 lines (1134 loc) · 46.7 KB
/
Copy pathProgram.cs
File metadata and controls
1288 lines (1134 loc) · 46.7 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
using DotNetEnv;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using SemanticKernelDevHub.Agents;
using SemanticKernelDevHub.Plugins;
using SemanticKernelDevHub.Models;
using SemanticKernelDevHub.Services;
// Load environment variables from .env file
Env.Load();
// Get configuration from environment variables
var endpoint = Environment.GetEnvironmentVariable("AOAI_ENDPOINT");
var apiKey = Environment.GetEnvironmentVariable("AOAI_APIKEY");
var deploymentName = Environment.GetEnvironmentVariable("CHATCOMPLETION_DEPLOYMENTNAME");
// Validate required configuration
if (
string.IsNullOrEmpty(endpoint)
|| string.IsNullOrEmpty(apiKey)
|| string.IsNullOrEmpty(deploymentName)
)
{
Console.WriteLine("❌ Missing required configuration. Please check your .env file.");
Console.WriteLine($"AOAI_ENDPOINT: {(string.IsNullOrEmpty(endpoint) ? "MISSING" : "✓")}");
Console.WriteLine($"AOAI_APIKEY: {(string.IsNullOrEmpty(apiKey) ? "MISSING" : "✓")}");
Console.WriteLine(
$"CHATCOMPLETION_DEPLOYMENTNAME: {(string.IsNullOrEmpty(deploymentName) ? "MISSING" : "✓")}"
);
return;
}
try
{
// Create kernel with Azure OpenAI chat completion service
var kernel = Kernel
.CreateBuilder()
.AddAzureOpenAIChatCompletion(
deploymentName: deploymentName,
endpoint: endpoint,
apiKey: apiKey
)
.Build();
Console.WriteLine("🎉 Hello Semantic Kernel!");
Console.WriteLine("✅ Semantic Kernel initialized successfully!");
Console.WriteLine($"📡 Connected to Azure OpenAI endpoint: {endpoint}");
Console.WriteLine($"🤖 Using deployment: {deploymentName}");
// Initialize GitHub Plugin
Console.WriteLine("\n🐙 Initializing GitHub integration...");
GitHubPlugin? gitHubPlugin = null;
var gitHubToken = Environment.GetEnvironmentVariable("GITHUB_TOKEN");
var gitHubOwner = Environment.GetEnvironmentVariable("GITHUB_REPO_OWNER");
var gitHubRepo = Environment.GetEnvironmentVariable("GITHUB_REPO_NAME");
if (
!string.IsNullOrEmpty(gitHubToken)
&& !string.IsNullOrEmpty(gitHubOwner)
&& !string.IsNullOrEmpty(gitHubRepo)
)
{
try
{
gitHubPlugin = new GitHubPlugin(gitHubToken, gitHubOwner, gitHubRepo);
kernel.ImportPluginFromObject(gitHubPlugin, "GitHub");
Console.WriteLine("✅ GitHubPlugin initialized and registered successfully");
}
catch (Exception ex)
{
Console.WriteLine($"⚠️ GitHub plugin initialization failed: {ex.Message}");
Console.WriteLine(
"📝 Code review will work in limited mode without GitHub integration"
);
}
}
else
{
Console.WriteLine("⚠️ GitHub configuration incomplete - some features will be limited");
Console.WriteLine(
"📝 Please ensure GITHUB_TOKEN, GITHUB_REPO_OWNER, and GITHUB_REPO_NAME are set"
);
}
// Initialize FileSystem Plugin
Console.WriteLine("\n📁 Initializing file system integration...");
var fileSystemPlugin = new FileSystemPlugin();
kernel.ImportPluginFromObject(fileSystemPlugin, "FileSystem");
Console.WriteLine("✅ FileSystemPlugin initialized and registered successfully");
// Initialize Jira Plugin
Console.WriteLine("\n🎫 Initializing Jira integration...");
JiraPlugin? jiraPlugin = null;
JiraIntegrationAgent? jiraIntegrationAgent = null;
var jiraUrl = Environment.GetEnvironmentVariable("JIRA_URL");
var jiraEmail = Environment.GetEnvironmentVariable("JIRA_EMAIL");
var jiraToken = Environment.GetEnvironmentVariable("JIRA_API_TOKEN");
var jiraProjectKey = Environment.GetEnvironmentVariable("JIRA_PROJECT_KEY");
if (
!string.IsNullOrEmpty(jiraUrl)
&& !string.IsNullOrEmpty(jiraEmail)
&& !string.IsNullOrEmpty(jiraToken)
&& !string.IsNullOrEmpty(jiraProjectKey)
)
{
try
{
jiraPlugin = new JiraPlugin(jiraUrl, jiraEmail, jiraToken, jiraProjectKey);
kernel.ImportPluginFromObject(jiraPlugin, "Jira");
// Test Jira connection
var connectionTest = await jiraPlugin.TestConnection();
Console.WriteLine($"🔌 {connectionTest}");
// Initialize JiraIntegrationAgent
jiraIntegrationAgent = new JiraIntegrationAgent(kernel, jiraPlugin, jiraProjectKey);
await jiraIntegrationAgent.InitializeAsync();
await jiraIntegrationAgent.RegisterFunctionsAsync(kernel);
Console.WriteLine("✅ JiraPlugin and JiraIntegrationAgent initialized successfully");
}
catch (Exception ex)
{
Console.WriteLine($"⚠️ Jira integration initialization failed: {ex.Message}");
Console.WriteLine("📝 Jira features will be disabled");
}
}
else
{
Console.WriteLine("⚠️ Jira configuration incomplete - Jira features will be disabled");
Console.WriteLine(
"📝 Please ensure JIRA_URL, JIRA_EMAIL, JIRA_API_TOKEN, and JIRA_PROJECT_KEY are set"
);
}
// Initialize and register CodeReviewAgent with GitHub plugin and Jira integration
Console.WriteLine("\n🤖 Initializing agents...");
var codeReviewAgent = new CodeReviewAgent(kernel, gitHubPlugin, jiraIntegrationAgent);
await codeReviewAgent.InitializeAsync();
await codeReviewAgent.RegisterFunctionsAsync(kernel);
// Initialize MeetingAnalysisAgent with FileSystem plugin
var meetingAnalysisAgent = new MeetingAnalysisAgent(kernel, fileSystemPlugin);
await meetingAnalysisAgent.InitializeAsync();
await meetingAnalysisAgent.RegisterFunctionsAsync(kernel);
// Initialize Intelligence Agent with all other agents
Console.WriteLine("\n🧠 Initializing Intelligence Agent...");
var intelligenceAgent = new IntelligenceAgent(
kernel,
codeReviewAgent,
meetingAnalysisAgent,
jiraIntegrationAgent
);
await intelligenceAgent.InitializeAsync();
await intelligenceAgent.RegisterFunctionsAsync(kernel);
// Initialize Orchestration Service
Console.WriteLine("🎭 Initializing Orchestration Service...");
var orchestrationService = new OrchestrationService(
kernel,
intelligenceAgent,
codeReviewAgent,
meetingAnalysisAgent,
jiraIntegrationAgent
);
Console.WriteLine("✅ Advanced orchestration capabilities ready");
// Get registered functions
var functions = kernel.Plugins.GetFunctionsMetadata();
Console.WriteLine(
$"📋 Available functions: [{string.Join(", ", functions.Select(f => f.Name))}]"
);
// Final status messages
if (gitHubPlugin != null && jiraPlugin != null)
{
Console.WriteLine("\n🧠 Semantic Kernel Intelligence Hub Ready!");
Console.WriteLine("✅ All agents initialized and cross-connected");
Console.WriteLine("✅ Memory system active");
Console.WriteLine("✅ Intelligence orchestration ready");
Console.WriteLine("✅ GitHubPlugin registered successfully");
Console.WriteLine("✅ FileSystemPlugin registered successfully");
Console.WriteLine("✅ JiraPlugin registered successfully");
Console.WriteLine("✅ CodeReviewAgent with GitHub capabilities ready");
Console.WriteLine("✅ MeetingAnalysisAgent ready for transcript processing");
Console.WriteLine("✅ JiraIntegrationAgent ready for ticket operations");
Console.WriteLine("🧠 IntelligenceAgent ready for cross-system analysis");
Console.WriteLine("🎭 OrchestrationService ready for complex workflows");
}
else if (gitHubPlugin != null)
{
Console.WriteLine("\n🎉 Semantic Kernel with GitHub + Meeting Analysis Ready!");
Console.WriteLine("✅ GitHubPlugin registered successfully");
Console.WriteLine("✅ FileSystemPlugin registered successfully");
Console.WriteLine("✅ CodeReviewAgent with GitHub capabilities ready");
Console.WriteLine("✅ MeetingAnalysisAgent ready for transcript processing");
Console.WriteLine("⚠️ Jira integration not available");
}
else if (jiraPlugin != null)
{
Console.WriteLine("\n🎉 Semantic Kernel with Jira + Meeting Analysis Ready!");
Console.WriteLine("✅ FileSystemPlugin registered successfully");
Console.WriteLine("✅ JiraPlugin registered successfully");
Console.WriteLine("✅ MeetingAnalysisAgent ready for transcript processing");
Console.WriteLine("✅ JiraIntegrationAgent ready for ticket operations");
Console.WriteLine("⚠️ GitHub integration not available");
}
else
{
Console.WriteLine("\n🎉 Semantic Kernel with Meeting Analysis Ready!");
Console.WriteLine("✅ FileSystemPlugin registered successfully");
Console.WriteLine("✅ MeetingAnalysisAgent ready for transcript processing");
}
// Interactive menu
await RunInteractiveMenu(
kernel,
codeReviewAgent,
gitHubPlugin,
meetingAnalysisAgent,
fileSystemPlugin,
jiraIntegrationAgent,
intelligenceAgent,
orchestrationService
);
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error initializing Semantic Kernel: {ex.Message}");
Console.WriteLine($"📋 Details: {ex}");
}
static async Task RunInteractiveMenu(
Kernel kernel,
CodeReviewAgent codeReviewAgent,
GitHubPlugin? gitHubPlugin,
MeetingAnalysisAgent meetingAnalysisAgent,
FileSystemPlugin fileSystemPlugin,
JiraIntegrationAgent? jiraIntegrationAgent,
IntelligenceAgent intelligenceAgent,
OrchestrationService orchestrationService
)
{
while (true)
{
Console.WriteLine("\n" + new string('=', 60));
Console.WriteLine("🧠 Semantic Kernel Intelligence Hub - Phase 6");
Console.WriteLine(new string('=', 60));
Console.WriteLine("Choose an option:");
if (gitHubPlugin != null && jiraIntegrationAgent != null)
{
Console.WriteLine("📝 Code Review & Analysis:");
Console.WriteLine("1. Review Latest Commit");
Console.WriteLine("2. List Recent Commits");
Console.WriteLine("3. Review Specific Commit");
Console.WriteLine("4. Review Pull Request");
Console.WriteLine("5. Analyze Custom Code");
Console.WriteLine("6. Check Coding Standards");
Console.WriteLine("7. Repository Information");
Console.WriteLine("\n💬 Meeting Analysis:");
Console.WriteLine("8. Process Meeting Transcript");
Console.WriteLine("9. Start File Watcher Mode");
Console.WriteLine("10. Analyze Sample Meeting");
Console.WriteLine("\n🎫 Jira Integration:");
Console.WriteLine("11. Test Jira Connection");
Console.WriteLine("12. Create Sample Jira Ticket");
Console.WriteLine("13. Update Existing Jira Ticket");
Console.WriteLine("\n🧠 Intelligence & Orchestration:");
Console.WriteLine("14. Generate Development Intelligence Report");
Console.WriteLine("15. Analyze Cross-References (Code ↔ Meetings ↔ Jira)");
Console.WriteLine("16. Predictive Insights Dashboard");
Console.WriteLine("17. Export Executive Summary");
Console.WriteLine("18. Execute Security Workflow");
Console.WriteLine("19. Execute Performance Workflow");
Console.WriteLine("20. Execute Sprint Planning Workflow");
Console.WriteLine("\n⚡ Quick Actions:");
Console.WriteLine("21. Exit");
}
else if (gitHubPlugin != null)
{
Console.WriteLine("1. Review Latest Commit");
Console.WriteLine("2. List Recent Commits");
Console.WriteLine("3. Review Specific Commit");
Console.WriteLine("4. Review Pull Request");
Console.WriteLine("5. Analyze Custom Code");
Console.WriteLine("6. Check Coding Standards");
Console.WriteLine("7. Repository Information");
Console.WriteLine("8. Process Meeting Transcript");
Console.WriteLine("9. Start File Watcher Mode");
Console.WriteLine("10. Analyze Sample Meeting");
Console.WriteLine("11. Exit");
}
else if (jiraIntegrationAgent != null)
{
Console.WriteLine("1. Test Code Review Agent");
Console.WriteLine("2. Analyze Sample Code");
Console.WriteLine("3. Check Coding Standards");
Console.WriteLine("4. Process Meeting Transcript");
Console.WriteLine("5. Start File Watcher Mode");
Console.WriteLine("6. Analyze Sample Meeting");
Console.WriteLine("7. Test Jira Connection");
Console.WriteLine("8. Create Sample Jira Ticket");
Console.WriteLine("9. Update Existing Jira Ticket");
Console.WriteLine("10. Exit");
}
else
{
Console.WriteLine("1. Test Code Review Agent");
Console.WriteLine("2. Analyze Sample Code");
Console.WriteLine("3. Check Coding Standards");
Console.WriteLine("4. Review GitHub Pull Request (Limited)");
Console.WriteLine("5. Process Meeting Transcript");
Console.WriteLine("6. Start File Watcher Mode");
Console.WriteLine("7. Analyze Sample Meeting");
Console.WriteLine("8. Exit");
}
var maxChoice =
(gitHubPlugin != null && jiraIntegrationAgent != null)
? "21"
: (gitHubPlugin != null)
? "11"
: (jiraIntegrationAgent != null)
? "10"
: "8";
Console.Write($"\nEnter your choice (1-{maxChoice}): ");
var choice = Console.ReadLine();
try
{
if (gitHubPlugin != null && jiraIntegrationAgent != null)
{
switch (choice)
{
case "1":
await ReviewLatestCommit(codeReviewAgent);
break;
case "2":
await ListRecentCommits(codeReviewAgent);
break;
case "3":
await ReviewSpecificCommit(codeReviewAgent);
break;
case "4":
await ReviewPullRequest(codeReviewAgent);
break;
case "5":
await AnalyzeSampleCode(codeReviewAgent);
break;
case "6":
await CheckCodingStandards(codeReviewAgent);
break;
case "7":
await ShowRepositoryInfo(gitHubPlugin);
break;
case "8":
await ProcessMeetingTranscript(meetingAnalysisAgent, fileSystemPlugin);
break;
case "9":
await StartFileWatcherMode(fileSystemPlugin, meetingAnalysisAgent);
break;
case "10":
await AnalyzeSampleMeeting(meetingAnalysisAgent);
break;
case "11":
await TestJiraConnection(jiraIntegrationAgent!);
break;
case "12":
await CreateSampleJiraTicket(jiraIntegrationAgent!);
break;
case "13":
await UpdateExistingJiraTicket(jiraIntegrationAgent!);
break;
case "14":
await GenerateDevelopmentIntelligenceReport(intelligenceAgent);
break;
case "15":
await AnalyzeCrossReferences(intelligenceAgent);
break;
case "16":
await ShowPredictiveInsightsDashboard(intelligenceAgent);
break;
case "17":
await ExportExecutiveSummary(intelligenceAgent);
break;
case "18":
await ExecuteSecurityWorkflow(orchestrationService);
break;
case "19":
await ExecutePerformanceWorkflow(orchestrationService);
break;
case "20":
await ExecuteSprintPlanningWorkflow(orchestrationService);
break;
case "21":
Console.WriteLine(
"\n👋 Thank you for using Semantic Kernel Intelligence Hub!"
);
return;
default:
Console.WriteLine("\n❌ Invalid choice. Please enter 1-21.");
break;
}
}
else
{
switch (choice)
{
case "1":
await TestCodeReviewAgent(codeReviewAgent);
break;
case "2":
await AnalyzeSampleCode(codeReviewAgent);
break;
case "3":
await CheckCodingStandards(codeReviewAgent);
break;
case "4":
await ReviewPullRequest(codeReviewAgent);
break;
case "5":
await ProcessMeetingTranscript(meetingAnalysisAgent, fileSystemPlugin);
break;
case "6":
await StartFileWatcherMode(fileSystemPlugin, meetingAnalysisAgent);
break;
case "7":
await AnalyzeSampleMeeting(meetingAnalysisAgent);
break;
case "8":
await TestJiraConnection(jiraIntegrationAgent!);
break;
case "9":
await CreateSampleJiraTicket(jiraIntegrationAgent!);
break;
case "10":
await UpdateExistingJiraTicket(jiraIntegrationAgent!);
break;
case "11":
Console.WriteLine("\n👋 Thank you for using Semantic Kernel DevHub!");
return;
default:
Console.WriteLine("\n❌ Invalid choice. Please enter 1-8.");
break;
}
}
}
catch (Exception ex)
{
Console.WriteLine($"\n❌ Error: {ex.Message}");
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
}
static async Task TestCodeReviewAgent(CodeReviewAgent agent)
{
Console.WriteLine("\n🧪 Testing Code Review Agent with different languages...");
// Test C# code
var csharpCode =
@"
public class Calculator
{
public int Add(int a, int b)
{
return a + b;
}
public int Divide(int a, int b)
{
return a / b;
}
}";
Console.WriteLine("📝 Analyzing sample C# Calculator class...");
var csharpResult = await agent.AnalyzeCode(csharpCode, "C#");
Console.WriteLine("\n📊 C# Analysis Result:");
Console.WriteLine(csharpResult);
Console.WriteLine("\n" + new string('-', 50));
// Test JavaScript code
var jsCode =
@"
function calculateTotal(items) {
var total = 0;
for (var i = 0; i < items.length; i++) {
total += items[i].price;
}
return total;
}";
Console.WriteLine("📝 Analyzing sample JavaScript function...");
var jsResult = await agent.AnalyzeCode(jsCode, "JavaScript");
Console.WriteLine("\n📊 JavaScript Analysis Result:");
Console.WriteLine(jsResult);
}
static async Task AnalyzeSampleCode(CodeReviewAgent agent)
{
Console.WriteLine("\n📝 Enter your code to analyze:");
Console.WriteLine("(Enter 'END' on a new line when finished)");
var codeLines = new List<string>();
string? line;
while ((line = Console.ReadLine()) != "END")
{
if (line != null)
codeLines.Add(line);
}
var code = string.Join("\n", codeLines);
if (string.IsNullOrWhiteSpace(code))
{
Console.WriteLine("❌ No code provided.");
return;
}
Console.WriteLine("\nSupported languages: C#, VB.NET, T-SQL, JavaScript, React, Java");
Console.Write("Enter programming language (or press Enter for 'C#'): ");
var language = Console.ReadLine();
if (string.IsNullOrWhiteSpace(language))
language = "C#";
Console.WriteLine($"\n🔍 Analyzing your {language} code...");
var result = await agent.AnalyzeCode(code, language);
Console.WriteLine("\n📊 Analysis Result:");
Console.WriteLine(result);
}
static async Task CheckCodingStandards(CodeReviewAgent agent)
{
Console.WriteLine("\n📋 Enter code to check against coding standards:");
Console.WriteLine("(Enter 'END' on a new line when finished)");
var codeLines = new List<string>();
string? line;
while ((line = Console.ReadLine()) != "END")
{
if (line != null)
codeLines.Add(line);
}
var code = string.Join("\n", codeLines);
if (string.IsNullOrWhiteSpace(code))
{
Console.WriteLine("❌ No code provided.");
return;
}
Console.WriteLine("\nSupported languages: C#, VB.NET, T-SQL, JavaScript, React, Java");
Console.Write("Enter programming language (or press Enter for 'C#'): ");
var language = Console.ReadLine();
if (string.IsNullOrWhiteSpace(language))
language = "C#";
Console.Write("Enter coding standard (or press Enter for language default): ");
var standard = Console.ReadLine();
if (string.IsNullOrWhiteSpace(standard))
standard = "Language Default";
Console.WriteLine($"\n📏 Checking {language} coding standards...");
var result = await agent.CheckCodingStandards(code, standard, language);
Console.WriteLine("\n📊 Standards Check Result:");
Console.WriteLine(result);
}
static async Task ReviewPullRequest(CodeReviewAgent agent)
{
Console.Write("\nEnter GitHub Pull Request number to review: ");
var prInput = Console.ReadLine();
if (!int.TryParse(prInput, out var prNumber))
{
Console.WriteLine("❌ Invalid pull request number.");
return;
}
Console.WriteLine($"\n🔍 Reviewing Pull Request #{prNumber}...");
var result = await agent.ReviewPullRequest(prNumber);
Console.WriteLine("\n📊 Pull Request Review:");
Console.WriteLine(result);
}
static async Task ReviewLatestCommit(CodeReviewAgent agent)
{
Console.WriteLine("\n🔍 Reviewing latest commit...");
try
{
var result = await agent.ReviewLatestCommit();
Console.WriteLine("\n📊 Latest Commit Review Result:");
Console.WriteLine(result.ToString());
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error reviewing latest commit: {ex.Message}");
}
}
static async Task ListRecentCommits(CodeReviewAgent agent)
{
Console.WriteLine("\n📝 Fetching recent commits...");
Console.Write("How many commits to show (1-20, default 10): ");
var countInput = Console.ReadLine();
if (!int.TryParse(countInput, out var count) || count < 1 || count > 20)
{
count = 10;
}
try
{
var commits = await agent.ListRecentCommits(count);
Console.WriteLine($"\n📝 Recent {commits.Count} commits:");
Console.WriteLine(new string('-', 60));
foreach (var commit in commits)
{
Console.WriteLine($" {commit.ShortSha} - {commit.Message.Split('\n')[0]}");
Console.WriteLine($" 👤 {commit.Author} | 📅 {commit.Date:yyyy-MM-dd HH:mm}");
// Display repository and branch information
var repoInfo = "";
if (!string.IsNullOrEmpty(commit.RepositoryName))
{
repoInfo = $"📦 {commit.RepositoryName}";
}
if (!string.IsNullOrEmpty(commit.BranchName))
{
repoInfo += string.IsNullOrEmpty(repoInfo) ? $"🌿 {commit.BranchName}" : $" | 🌿 {commit.BranchName}";
}
if (!string.IsNullOrEmpty(repoInfo))
{
Console.WriteLine($" {repoInfo}");
}
if (commit.FilesChanged.Any())
{
Console.WriteLine(
$" 📁 {commit.FilesChanged.Count} files changed (+{commit.TotalAdditions}/-{commit.TotalDeletions})"
);
}
Console.WriteLine();
}
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error fetching commits: {ex.Message}");
}
}
static async Task ReviewSpecificCommit(CodeReviewAgent agent)
{
Console.Write("\nEnter commit SHA to review: ");
var commitSha = Console.ReadLine();
if (string.IsNullOrWhiteSpace(commitSha))
{
Console.WriteLine("❌ No commit SHA provided.");
return;
}
Console.WriteLine($"\n🔍 Reviewing commit {commitSha}...");
try
{
var result = await agent.ReviewCommit(commitSha);
Console.WriteLine("\n📊 Commit Review Result:");
Console.WriteLine(result.ToString());
if (result.FileReviews.Any())
{
Console.WriteLine("\n📋 Individual File Reviews:");
Console.WriteLine(new string('-', 60));
foreach (var fileReview in result.FileReviews)
{
Console.WriteLine($"📄 {fileReview.FileName} ({fileReview.Language})");
Console.WriteLine($" Score: {fileReview.Score}/10");
if (fileReview.Issues.Any())
{
Console.WriteLine($" Issues: {string.Join(", ", fileReview.Issues.Take(2))}");
}
Console.WriteLine();
}
}
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error reviewing commit: {ex.Message}");
}
}
static async Task ShowRepositoryInfo(GitHubPlugin gitHubPlugin)
{
Console.WriteLine("\n📊 Fetching repository information...");
try
{
var repoInfo = await gitHubPlugin.GetRepositoryInfo();
var repo = System.Text.Json.JsonSerializer.Deserialize<dynamic>(repoInfo);
Console.WriteLine("\n📋 Repository Information:");
Console.WriteLine(new string('-', 50));
Console.WriteLine($"Name: {repo?.GetProperty("Name").GetString()}");
Console.WriteLine(
$"Description: {repo?.GetProperty("Description").GetString() ?? "No description"}"
);
Console.WriteLine($"Language: {repo?.GetProperty("Language").GetString() ?? "Mixed"}");
Console.WriteLine($"Stars: {repo?.GetProperty("StargazersCount").GetInt32()}");
Console.WriteLine($"Forks: {repo?.GetProperty("ForksCount").GetInt32()}");
Console.WriteLine($"Open Issues: {repo?.GetProperty("OpenIssuesCount").GetInt32()}");
Console.WriteLine($"Default Branch: {repo?.GetProperty("DefaultBranch").GetString()}");
Console.WriteLine($"Created: {repo?.GetProperty("CreatedAt").GetDateTime():yyyy-MM-dd}");
Console.WriteLine(
$"Last Updated: {repo?.GetProperty("UpdatedAt").GetDateTime():yyyy-MM-dd}"
);
Console.WriteLine($"URL: {repo?.GetProperty("Url").GetString()}");
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error fetching repository info: {ex.Message}");
}
}
/// <summary>
/// Processes a meeting transcript file
/// </summary>
static async Task ProcessMeetingTranscript(
MeetingAnalysisAgent meetingAgent,
FileSystemPlugin fileSystemPlugin
)
{
try
{
Console.WriteLine("\n📂 Processing meeting transcript...");
var incomingFiles = await fileSystemPlugin.ListIncomingFiles();
if (!incomingFiles.Any())
{
Console.WriteLine("📁 No transcript files found. Copy files to Data/Incoming/ folder.");
return;
}
var selectedFile = incomingFiles[0]; // Use first file for simplicity
var fileName = Path.GetFileName(selectedFile);
Console.WriteLine($"🔍 Processing: {fileName}");
var result = await meetingAgent.ProcessTranscriptFile(selectedFile);
Console.WriteLine(result.GetFormattedSummary());
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error: {ex.Message}");
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
/// <summary>
/// Starts file watcher mode
/// </summary>
static Task StartFileWatcherMode(
FileSystemPlugin fileSystemPlugin,
MeetingAnalysisAgent meetingAgent
)
{
Console.WriteLine("\n📡 File watcher mode activated. Press any key to return to menu...");
Console.ReadKey();
return Task.CompletedTask;
}
/// <summary>
/// Analyzes a sample meeting
/// </summary>
static async Task AnalyzeSampleMeeting(MeetingAnalysisAgent meetingAgent)
{
try
{
Console.WriteLine("\n📋 Processing sample meeting transcript...");
var result = await meetingAgent.AnalyzeSampleMeeting(0);
Console.WriteLine(result.GetFormattedSummary());
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error: {ex.Message}");
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
static async Task TestJiraConnection(JiraIntegrationAgent jiraAgent)
{
Console.WriteLine("\n🔌 Testing Jira connection...");
Console.WriteLine("✅ Jira connection test would run here");
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
static async Task CreateSampleJiraTicket(JiraIntegrationAgent jiraAgent)
{
Console.WriteLine("\n🎫 Creating sample Jira ticket...");
Console.WriteLine("✅ Sample ticket creation would run here");
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
static async Task UpdateExistingJiraTicket(JiraIntegrationAgent jiraAgent)
{
Console.WriteLine("\n🎫 Updating Jira ticket...");
Console.WriteLine("✅ Ticket update would run here");
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
// Intelligence Agent Handler Methods
static async Task GenerateDevelopmentIntelligenceReport(IntelligenceAgent intelligenceAgent)
{
Console.WriteLine("\n🧠 Generating Development Intelligence Report...");
try
{
var report = await intelligenceAgent.GenerateDevelopmentIntelligenceReport(7, true);
Console.WriteLine($"\n📊 **DEVELOPMENT INTELLIGENCE REPORT**");
Console.WriteLine($"📅 Period: {report.Period.FriendlyDescription}");
Console.WriteLine($"🏥 Health Score: {report.OverallHealthScore}/100");
Console.WriteLine($"\n📈 **KEY METRICS**:");
Console.WriteLine($"• Commits: {report.Metrics.TotalCommits}");
Console.WriteLine($"• Code Reviews: {report.Metrics.TotalCodeReviews}");
Console.WriteLine($"• Meetings: {report.Metrics.TotalMeetings}");
Console.WriteLine($"• Jira Tickets: {report.Metrics.TotalJiraTickets}");
Console.WriteLine(
$"• Action Item Completion: {report.Metrics.ActionItemCompletionRate:F1}%"
);
Console.WriteLine($"\n🔍 **KEY INSIGHTS**:");
foreach (var insight in report.Insights.Take(3))
{
Console.WriteLine($"• {insight.Title}: {insight.Description}");
}
Console.WriteLine($"\n💡 **TOP RECOMMENDATIONS**:");
foreach (var rec in report.Predictions.Take(3))
{
Console.WriteLine($"• {rec.Title} ({rec.Priority})");
}
Console.WriteLine($"\n📋 **EXECUTIVE SUMMARY**:");
Console.WriteLine(report.ExecutiveSummary);
Console.WriteLine("\n✅ Report complete!");
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error generating report: {ex.Message}");
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
static async Task AnalyzeCrossReferences(IntelligenceAgent intelligenceAgent)
{
Console.WriteLine("\n🔗 Analyzing Cross-References Between Systems...");
try
{
var crossRef = await intelligenceAgent.AnalyzeCrossReferences("FullSystemAnalysis");
Console.WriteLine($"\n🔍 **CROSS-REFERENCE ANALYSIS**");
Console.WriteLine($"📊 Confidence Score: {crossRef.ConfidenceScore:F2}");
Console.WriteLine($"🔗 Connections Found: {crossRef.Connections.Count}");
Console.WriteLine($"📝 Entities Analyzed: {crossRef.RelatedEntities.Count}");
Console.WriteLine($"\n💡 **KEY INSIGHTS**:");
foreach (var insight in crossRef.KeyInsights)
{
Console.WriteLine($"• {insight}");
}
Console.WriteLine($"\n🔍 **CONNECTION PATTERNS**:");
foreach (var pattern in crossRef.Patterns.Take(3))
{
Console.WriteLine(
$"• {pattern.Name}: {pattern.Description} (Confidence: {pattern.Confidence:F2})"
);
}
Console.WriteLine($"\n📋 **SUMMARY**:");
Console.WriteLine(crossRef.Summary);
// Show specific correlations
var correlationReport = await intelligenceAgent.AnalyzeCodeMeetingCorrelations();
Console.WriteLine($"\n🔗 **CODE ↔ MEETING CORRELATIONS**:");
Console.WriteLine(correlationReport);
Console.WriteLine("\n✅ Cross-reference analysis complete!");
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error analyzing cross-references: {ex.Message}");
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
static async Task ShowPredictiveInsightsDashboard(IntelligenceAgent intelligenceAgent)
{
Console.WriteLine("\n🔮 Generating Predictive Insights Dashboard...");
try
{
var predictions = await intelligenceAgent.GeneratePredictiveInsights(14);
Console.WriteLine($"\n🔮 **PREDICTIVE INSIGHTS DASHBOARD**");
Console.WriteLine($"🎯 Prediction Horizon: 14 days");
Console.WriteLine($"📊 Total Predictions: {predictions.Count}");
// Group by category
var groupedPredictions = predictions.GroupBy(p => p.Category);
foreach (var group in groupedPredictions)
{
Console.WriteLine($"\n📂 **{group.Key.ToString().ToUpper()}**:");
foreach (var prediction in group.Take(2))
{
Console.WriteLine($"• {prediction.Title}");
Console.WriteLine(
$" Priority: {prediction.Priority} | Confidence: {prediction.Confidence:F2}"
);
Console.WriteLine($" Expected Impact: {prediction.ExpectedImpact}");
Console.WriteLine($" Time Frame: {prediction.TimeFrame}");
Console.WriteLine($" Description: {prediction.Description}");
if (prediction.ActionSteps.Any())
{
Console.WriteLine(
$" Action Steps: {prediction.ActionSteps.Count} steps defined"
);
}
Console.WriteLine();
}
}
// Highlight critical predictions
var criticalPredictions = predictions
.Where(p => p.Priority == RecommendationPriority.Critical)
.ToList();
if (criticalPredictions.Any())
{
Console.WriteLine($"\n⚠️ **CRITICAL ATTENTION REQUIRED**:");
foreach (var critical in criticalPredictions)
{
Console.WriteLine($"🚨 {critical.Title}: {critical.Description}");
}
}
Console.WriteLine("\n✅ Predictive insights dashboard complete!");
}
catch (Exception ex)
{
Console.WriteLine($"❌ Error generating predictive insights: {ex.Message}");
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
static async Task ExportExecutiveSummary(IntelligenceAgent intelligenceAgent)
{
Console.WriteLine("\n📋 Generating Executive Summary...");
try
{
var executiveSummary = await intelligenceAgent.CreateExecutiveSummary("Overall");
Console.WriteLine($"\n📋 **EXECUTIVE SUMMARY**");
Console.WriteLine(new string('=', 50));
Console.WriteLine(executiveSummary);
Console.WriteLine(new string('=', 50));