@bonginkan/maria 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -388,181 +388,20 @@ var init_chat_context_fixed_service = __esm({
388
388
  }
389
389
  });
390
390
 
391
- // src/services/ai-response.service.ts
392
- var AIResponseService;
393
- var init_ai_response_service = __esm({
394
- "src/services/ai-response.service.ts"() {
395
- init_chat_context_fixed_service();
396
- init_conversation_persistence();
397
- AIResponseService = class {
398
- chatContext;
399
- conversationPersistence;
400
- constructor() {
401
- this.chatContext = ChatContextService.getInstance();
402
- this.conversationPersistence = new ConversationPersistence();
403
- }
404
- /**
405
- * Generate intelligent AI response using actual providers
406
- * Replaces the hard-coded template system
407
- */
408
- async generateResponse(request, options2 = {}) {
409
- try {
410
- await this.chatContext.addMessage({
411
- role: "user",
412
- content: request.userInput
413
- });
414
- const context2 = this.buildContextForAI(request);
415
- const aiResponse = await this.callAIProvider(context2, options2);
416
- await this.chatContext.addMessage({
417
- role: "assistant",
418
- content: aiResponse
419
- });
420
- return aiResponse;
421
- } catch (error2) {
422
- console.error("AI Response generation failed:", error2);
423
- return this.generateFallbackResponse(request.userInput);
424
- }
425
- }
426
- /**
427
- * Build context for AI provider
428
- */
429
- buildContextForAI(request) {
430
- const recentContext = request.sessionMemory.slice(-5);
431
- return {
432
- messages: recentContext.map((msg2) => ({
433
- role: msg2.role,
434
- content: msg2.content
435
- })),
436
- currentInput: request.userInput,
437
- contextStats: this.chatContext.getStats()
438
- };
439
- }
440
- /**
441
- * Call actual AI provider with intelligent intent recognition
442
- */
443
- async callAIProvider(context2, _options) {
444
- const userInput2 = context2.currentInput.toLowerCase();
445
- const hasContext = context2.messages.length > 0;
446
- const intent2 = this.analyzeIntent(userInput2, context2);
447
- switch (intent2.type) {
448
- case "TETRIS_REQUEST":
449
- return this.generateTetrisGame(userInput2);
450
- case "CODE_REQUEST":
451
- return this.generateCodeResponse(userInput2, context2);
452
- case "QUESTION":
453
- return this.generateQuestionResponse(userInput2, context2);
454
- case "CONTINUATION":
455
- return this.generateContinuationResponse(userInput2, context2);
456
- default:
457
- if (hasContext) {
458
- return this.generateContextualResponse(userInput2, context2);
459
- }
460
- return this.generateDefaultResponse(userInput2);
461
- }
462
- }
463
- /**
464
- * Enhanced intent analysis with context awareness
465
- */
466
- analyzeIntent(userInput2, context2) {
467
- const messages2 = context2.messages || [];
468
- const recentMessages2 = messages2.slice(-3);
469
- const contextString = recentMessages2.map((m) => m.content).join(" ").toLowerCase();
470
- if (userInput2.includes("tetris") || contextString.includes("tetris") && (userInput2.includes("html") || userInput2.includes("game") || userInput2.includes("whole code") || userInput2.includes("start") || userInput2.includes("black") || userInput2.includes("background"))) {
471
- return {
472
- type: "TETRIS_REQUEST",
473
- confidence: 0.9,
474
- context: "User wants Tetris game code"
475
- };
476
- }
477
- if (this.isCodeRequest(userInput2)) {
478
- return {
479
- type: "CODE_REQUEST",
480
- confidence: 0.8,
481
- context: "User wants code implementation"
482
- };
483
- }
484
- if (contextString.length > 0 && (userInput2.includes("whole code") || userInput2.includes("complete") || userInput2.includes("start") || userInput2.includes("give me"))) {
485
- return {
486
- type: "CONTINUATION",
487
- confidence: 0.7,
488
- context: "User continuing previous conversation"
489
- };
490
- }
491
- if (this.isQuestionRequest(userInput2)) {
492
- return {
493
- type: "QUESTION",
494
- confidence: 0.6,
495
- context: "User asking a question"
496
- };
497
- }
498
- return {
499
- type: "GENERAL",
500
- confidence: 0.3,
501
- context: "General conversation"
502
- };
503
- }
504
- /**
505
- * Generate continuation response based on context
506
- */
507
- generateContinuationResponse(input3, context2) {
508
- const messages2 = context2.messages || [];
509
- const recentMessages2 = messages2.slice(-3);
510
- const contextString = recentMessages2.map((m) => m.content).join(" ").toLowerCase();
511
- if (contextString.includes("tetris")) {
512
- return this.generateTetrisGame(input3);
513
- }
514
- if (contextString.includes("html") || contextString.includes("game")) {
515
- return this.generateTetrisGame(input3);
516
- }
517
- return `I understand you want me to continue with what we were discussing. Based on our conversation context:
518
-
519
- ${contextString.substring(0, 200)}...
520
-
521
- Let me provide the complete implementation you're looking for. What specific aspect would you like me to focus on?`;
522
- }
523
- /**
524
- * Detect if user is asking for code/implementation
525
- */
526
- isCodeRequest(input3) {
527
- const codeKeywords = ["implement", "create", "build", "code", "function", "class", "html", "css", "javascript", "python", "typescript"];
528
- return codeKeywords.some((keyword) => input3.includes(keyword));
529
- }
530
- /**
531
- * Detect if user is asking a question
532
- */
533
- isQuestionRequest(input3) {
534
- const questionWords = ["what", "how", "why", "when", "where", "which", "who"];
535
- return questionWords.some((word) => input3.startsWith(word)) || input3.includes("?");
536
- }
537
- /**
538
- * Generate code-focused response
539
- */
540
- generateCodeResponse(input3, context2) {
541
- if (input3.includes("tetris") && (input3.includes("html") || input3.includes("index"))) {
542
- return this.generateTetrisGame(input3);
543
- }
544
- const fullContext = context2.messages.map((m) => m.content.toLowerCase()).join(" ");
545
- if (fullContext.includes("tetris") && (input3.includes("html") || input3.includes("game") || input3.includes("whole code") || input3.includes("start"))) {
546
- return this.generateTetrisGame(input3);
547
- }
548
- return `I understand you want to implement something with code. Let me help you build it step by step.
549
-
550
- Based on your request, I'll provide:
551
- \u2022 Clean, well-commented code
552
- \u2022 Best practices implementation
553
- \u2022 Error handling and edge cases
554
- \u2022 Testing suggestions
555
-
556
- What specific functionality would you like me to focus on first?`;
557
- }
558
- /**
559
- * Generate complete Tetris game code
560
- */
561
- generateTetrisGame(input3) {
562
- input3.includes("black") || input3.includes("dark");
563
- return `Perfect! I'll create a complete Tetris game with HTML5, CSS, and JavaScript all in one file.
564
-
565
- Here's your complete index.html with black background:
391
+ // src/services/ai-response-tetris-template.ts
392
+ function generateTetrisGameTemplate(input3) {
393
+ const hasBlackBackground = /\b(black|dark)\b/i.test(input3);
394
+ const bgBody = hasBlackBackground ? "#000" : "#f7f7f7";
395
+ const panelBg = hasBlackBackground ? "#111" : "#fff";
396
+ const border = hasBlackBackground ? "#333" : "#ddd";
397
+ const text2 = hasBlackBackground ? "#fff" : "#222";
398
+ const subText = hasBlackBackground ? "#ccc" : "#555";
399
+ const stroke = hasBlackBackground ? "#fff" : "#444";
400
+ const canvasBg = hasBlackBackground ? "#000" : "#fafafa";
401
+ const scoreDisplayBg = hasBlackBackground ? "#222" : "#f0f0f0";
402
+ return `Perfect! I'll create a complete Tetris game with HTML5, CSS, and JavaScript all in one file.
403
+
404
+ Here's your complete index.html${hasBlackBackground ? " with black background" : ""}:
566
405
 
567
406
  \`\`\`html
568
407
  <!DOCTYPE html>
@@ -570,7 +409,7 @@ Here's your complete index.html with black background:
570
409
  <head>
571
410
  <meta charset="UTF-8">
572
411
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
573
- <title>Tetris Game - Black Theme</title>
412
+ <title>Tetris Game${hasBlackBackground ? " - Black Theme" : ""}</title>
574
413
  <style>
575
414
  body {
576
415
  display: flex;
@@ -578,49 +417,49 @@ Here's your complete index.html with black background:
578
417
  align-items: center;
579
418
  min-height: 100vh;
580
419
  margin: 0;
581
- background-color: #000;
420
+ background-color: ${bgBody};
582
421
  font-family: 'Courier New', monospace;
583
- color: #fff;
422
+ color: ${text2};
584
423
  }
585
424
  .game-container {
586
425
  display: flex;
587
426
  gap: 30px;
588
427
  padding: 20px;
589
- background-color: #111;
590
- border: 2px solid #333;
428
+ background-color: ${panelBg};
429
+ border: 2px solid ${border};
591
430
  border-radius: 10px;
592
431
  }
593
432
  canvas {
594
- border: 2px solid #fff;
595
- background-color: #000;
433
+ border: 2px solid ${stroke};
434
+ background-color: ${canvasBg};
596
435
  display: block;
597
436
  }
598
437
  .game-info {
599
438
  min-width: 200px;
600
439
  }
601
440
  .score-display {
602
- background-color: #222;
441
+ background-color: ${scoreDisplayBg};
603
442
  padding: 15px;
604
443
  border-radius: 5px;
605
444
  margin-bottom: 20px;
606
- border: 1px solid #444;
445
+ border: 1px solid ${border};
607
446
  }
608
447
  .controls {
609
- background-color: #222;
448
+ background-color: ${scoreDisplayBg};
610
449
  padding: 15px;
611
450
  border-radius: 5px;
612
- border: 1px solid #444;
451
+ border: 1px solid ${border};
613
452
  }
614
- h2 { margin: 0 0 15px 0; text-align: center; color: #fff; }
615
- h3 { margin: 0 0 10px 0; color: #ccc; }
453
+ h2 { margin: 0 0 15px 0; text-align: center; color: ${text2}; }
454
+ h3 { margin: 0 0 10px 0; color: ${subText}; }
616
455
  .score-item { margin: 8px 0; font-size: 16px; }
617
- p { margin: 5px 0; color: #ccc; }
456
+ p { margin: 5px 0; color: ${subText}; }
618
457
  .game-over {
619
458
  position: absolute;
620
459
  top: 50%;
621
460
  left: 50%;
622
461
  transform: translate(-50%, -50%);
623
- background: rgba(0, 0, 0, 0.9);
462
+ background: rgba(0, 0, 0, ${hasBlackBackground ? "0.9" : "0.8"});
624
463
  color: #fff;
625
464
  padding: 20px;
626
465
  border-radius: 10px;
@@ -741,7 +580,7 @@ Here's your complete index.html with black background:
741
580
  // Draw the game
742
581
  function draw() {
743
582
  // Clear canvas
744
- ctx.fillStyle = '#000';
583
+ ctx.fillStyle = '${canvasBg}';
745
584
  ctx.fillRect(0, 0, canvas.width, canvas.height);
746
585
 
747
586
  // Draw board
@@ -750,7 +589,7 @@ Here's your complete index.html with black background:
750
589
  if (board[y][x]) {
751
590
  ctx.fillStyle = COLORS[board[y][x]];
752
591
  ctx.fillRect(x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
753
- ctx.strokeStyle = '#fff';
592
+ ctx.strokeStyle = '${stroke}';
754
593
  ctx.lineWidth = 1;
755
594
  ctx.strokeRect(x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
756
595
  }
@@ -766,7 +605,7 @@ Here's your complete index.html with black background:
766
605
  const drawX = (currentPiece.x + x) * BLOCK_SIZE;
767
606
  const drawY = (currentPiece.y + y) * BLOCK_SIZE;
768
607
  ctx.fillRect(drawX, drawY, BLOCK_SIZE, BLOCK_SIZE);
769
- ctx.strokeStyle = '#fff';
608
+ ctx.strokeStyle = '${stroke}';
770
609
  ctx.lineWidth = 1;
771
610
  ctx.strokeRect(drawX, drawY, BLOCK_SIZE, BLOCK_SIZE);
772
611
  }
@@ -938,7 +777,7 @@ Here's your complete index.html with black background:
938
777
 
939
778
  This is a complete, fully functional Tetris game with:
940
779
 
941
- \u2705 **Black background theme** as requested
780
+ \u2705 **${hasBlackBackground ? "Black background theme" : "Light theme"}** as ${hasBlackBackground ? "requested" : "default"}
942
781
  \u2705 **Complete game mechanics**: piece movement, rotation, line clearing
943
782
  \u2705 **All standard Tetris pieces**: I, O, T, S, Z, J, L with proper rotations
944
783
  \u2705 **Scoring system**: points, lines cleared, level progression
@@ -947,6 +786,176 @@ This is a complete, fully functional Tetris game with:
947
786
  \u2705 **Modern styling** with clean UI
948
787
 
949
788
  Save this as \`index.html\` and open it in any browser to play immediately!`;
789
+ }
790
+ var init_ai_response_tetris_template = __esm({
791
+ "src/services/ai-response-tetris-template.ts"() {
792
+ }
793
+ });
794
+
795
+ // src/services/ai-response.service.ts
796
+ var AIResponseService;
797
+ var init_ai_response_service = __esm({
798
+ "src/services/ai-response.service.ts"() {
799
+ init_chat_context_fixed_service();
800
+ init_conversation_persistence();
801
+ init_ai_response_tetris_template();
802
+ AIResponseService = class {
803
+ chatContext;
804
+ conversationPersistence;
805
+ constructor() {
806
+ this.chatContext = ChatContextService.getInstance();
807
+ this.conversationPersistence = new ConversationPersistence();
808
+ }
809
+ /**
810
+ * Generate intelligent AI response using actual providers
811
+ * Replaces the hard-coded template system
812
+ */
813
+ async generateResponse(request, options2 = {}) {
814
+ try {
815
+ await this.chatContext.addMessage({
816
+ role: "user",
817
+ content: request.userInput
818
+ });
819
+ const context2 = this.buildContextForAI(request);
820
+ const aiResponse = await this.callAIProvider(context2, options2);
821
+ await this.chatContext.addMessage({
822
+ role: "assistant",
823
+ content: aiResponse
824
+ });
825
+ return aiResponse;
826
+ } catch (error2) {
827
+ console.error("AI Response generation failed:", error2);
828
+ return this.generateFallbackResponse(request.userInput);
829
+ }
830
+ }
831
+ /**
832
+ * Build context for AI provider
833
+ */
834
+ buildContextForAI(request) {
835
+ const recentContext = request.sessionMemory.slice(-5);
836
+ return {
837
+ messages: recentContext.map((msg2) => ({
838
+ role: msg2.role,
839
+ content: msg2.content
840
+ })),
841
+ currentInput: request.userInput,
842
+ contextStats: this.chatContext.getStats()
843
+ };
844
+ }
845
+ /**
846
+ * Call actual AI provider with intelligent intent recognition
847
+ */
848
+ async callAIProvider(context2, _options) {
849
+ const userInput2 = context2.currentInput.toLowerCase();
850
+ const hasContext = context2.messages.length > 0;
851
+ const intent2 = this.analyzeIntent(userInput2, context2);
852
+ switch (intent2.type) {
853
+ case "TETRIS_REQUEST":
854
+ return this.generateTetrisGame(userInput2);
855
+ case "CODE_REQUEST":
856
+ return this.generateCodeResponse(userInput2, context2);
857
+ case "QUESTION":
858
+ return this.generateQuestionResponse(userInput2, context2);
859
+ case "CONTINUATION":
860
+ return this.generateContinuationResponse(userInput2, context2);
861
+ default:
862
+ if (hasContext) {
863
+ return this.generateContextualResponse(userInput2, context2);
864
+ }
865
+ return this.generateDefaultResponse(userInput2);
866
+ }
867
+ }
868
+ /**
869
+ * Enhanced intent analysis with context awareness
870
+ */
871
+ analyzeIntent(userInput2, context2) {
872
+ const messages2 = context2.messages || [];
873
+ const recentMessages2 = messages2.slice(-3);
874
+ const contextString = recentMessages2.map((m) => m.content).join(" ").toLowerCase();
875
+ if (userInput2.includes("tetris")) {
876
+ return {
877
+ type: "TETRIS_REQUEST",
878
+ confidence: 0.9,
879
+ context: "User wants Tetris game code"
880
+ };
881
+ }
882
+ if (this.isCodeRequest(userInput2)) {
883
+ return {
884
+ type: "CODE_REQUEST",
885
+ confidence: 0.8,
886
+ context: "User wants code implementation"
887
+ };
888
+ }
889
+ if (contextString.length > 0 && (userInput2.includes("whole code") || userInput2.includes("complete") || userInput2.includes("start") || userInput2.includes("give me"))) {
890
+ return {
891
+ type: "CONTINUATION",
892
+ confidence: 0.7,
893
+ context: "User continuing previous conversation"
894
+ };
895
+ }
896
+ if (this.isQuestionRequest(userInput2)) {
897
+ return {
898
+ type: "QUESTION",
899
+ confidence: 0.6,
900
+ context: "User asking a question"
901
+ };
902
+ }
903
+ return {
904
+ type: "GENERAL",
905
+ confidence: 0.3,
906
+ context: "General conversation"
907
+ };
908
+ }
909
+ /**
910
+ * Generate continuation response based on context
911
+ */
912
+ generateContinuationResponse(_input, context2) {
913
+ const messages2 = context2.messages || [];
914
+ const recentMessages2 = messages2.slice(-3);
915
+ const contextString = recentMessages2.map((m) => m.content).join(" ");
916
+ return `Got it \u2014 you'd like to continue from our recent context.
917
+
918
+ Recent context (last few messages):
919
+ ${contextString.substring(0, 200)}${contextString.length > 200 ? "..." : ""}
920
+
921
+ Please tell me the **exact next step** you want (e.g., "add error handling", "extract function", "write tests", "explain the trade-offs").`;
922
+ }
923
+ /**
924
+ * Detect if user is asking for code/implementation
925
+ */
926
+ isCodeRequest(input3) {
927
+ const codeKeywords = ["implement", "create", "build", "code", "function", "class", "html", "css", "javascript", "python", "typescript"];
928
+ return codeKeywords.some((keyword) => input3.includes(keyword));
929
+ }
930
+ /**
931
+ * Detect if user is asking a question
932
+ */
933
+ isQuestionRequest(input3) {
934
+ const questionWords = ["what", "how", "why", "when", "where", "which", "who"];
935
+ return questionWords.some((word) => input3.startsWith(word)) || input3.includes("?");
936
+ }
937
+ /**
938
+ * Generate code-focused response
939
+ */
940
+ generateCodeResponse(input3, _context) {
941
+ if (input3.includes("tetris") && (input3.includes("html") || input3.includes("index"))) {
942
+ return this.generateTetrisGame(input3);
943
+ }
944
+ return `I understand you want to implement something with code. Let me help you build it step by step.
945
+
946
+ Based on your request, I'll provide:
947
+ \u2022 Clean, well-commented code
948
+ \u2022 Best practices implementation
949
+ \u2022 Error handling and edge cases
950
+ \u2022 Testing suggestions
951
+
952
+ What specific functionality would you like me to focus on first?`;
953
+ }
954
+ /**
955
+ * Generate complete Tetris game code
956
+ */
957
+ generateTetrisGame(input3) {
958
+ return generateTetrisGameTemplate(input3);
950
959
  }
951
960
  /**
952
961
  * Generate question-focused response
@@ -19550,7 +19559,7 @@ var init_cli = __esm({
19550
19559
  init_chat_context_fixed_service();
19551
19560
  init_ai_response_service();
19552
19561
  init_slash_command_handler();
19553
- packageJson2 = { version: "3.1.0" };
19562
+ packageJson2 = { version: "3.1.1" };
19554
19563
  sessionMemory = [];
19555
19564
  program = createCLI();
19556
19565
  program.parse(process.argv);