Spaces:
Sleeping
Sleeping
File size: 48,999 Bytes
b4deece 3a826be cd0f5b1 3a826be 05cb78e 3a826be 05cb78e 3a826be b4deece 3a826be b4deece 3a826be 822c184 3a826be 05cb78e 3a826be 05cb78e 3a826be b4deece 3a826be b4deece 3a826be b4deece 3a826be cd0f5b1 3a826be b4deece 3a826be b4deece 05cb78e 3a826be b4deece 3a826be b4deece 3a826be 05cb78e b4deece 3a826be b4deece 3a826be b4deece 3a826be b4deece 3a826be b4deece 3a826be b4deece 3a826be b4deece 3a826be b4deece 3a826be cd0f5b1 05cb78e cd0f5b1 3a826be 822c184 3a826be 1fc2334 3a826be 1fc2334 3a826be f971627 3a826be 822c184 f971627 3a826be 822c184 f971627 822c184 3a826be d2ce69f cd0f5b1 d2ce69f cd0f5b1 d2ce69f cd0f5b1 d2ce69f cd0f5b1 d2ce69f cd0f5b1 3a826be cd0f5b1 3a826be cd0f5b1 3a826be 05cb78e 3a826be b4deece | 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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CodeBug β AI Code Review</title>
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;0,900;1,700&family=DM+Mono:wght@400;500&family=Syne:wght@400;600;700;800&display=swap" rel="stylesheet" />
<style>
/* ββ TOKENS βββββββββββββββββββββββββββββββββββββββββββββββ */
:root {
--ink: #0e0e0c;
--paper: #f2efe8;
--surface:#e8e4dc;
--mid: #b8b3aa;
--dim: #7a756c;
--mono: 'DM Mono', monospace;
--serif: 'Playfair Display', serif;
--sans: 'Syne', sans-serif;
}
/* ββ RESET ββββββββββββββββββββββββββββββββββββββββββββββββ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
background: var(--paper);
color: var(--ink);
font-family: var(--sans);
overflow-x: hidden;
}
/* subtle grain β opacity kept very low so it doesn't fight text */
body::before {
content: '';
position: fixed; inset: 0; z-index: 9000;
pointer-events: none;
opacity: .09;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
background-size: 200px 200px;
}
/* ββ NAV βββββββββββββββββββββββββββββββββββββββββββββββββββ */
nav {
position: fixed; top: 0; left: 0; right: 0; z-index: 500;
display: flex; align-items: center; justify-content: space-between;
padding: 20px 56px;
border-bottom: 1px solid rgba(14,14,12,.08);
backdrop-filter: blur(14px);
background: rgba(242,239,232,.92);
}
.nav-logo {
font-family: var(--serif);
font-size: 1.25rem; font-weight: 900; letter-spacing: -.02em;
display: flex; align-items: center; gap: 8px;
}
.nav-logo sup {
font-family: var(--mono); font-size: .5rem;
background: var(--ink); color: var(--paper);
padding: 2px 6px; border-radius: 2px; letter-spacing: .06em;
vertical-align: super;
}
.nav-links { display: flex; gap: 36px; list-style: none; }
.nav-links a {
font-size: .72rem; font-weight: 600;
letter-spacing: .1em; text-transform: uppercase;
text-decoration: none; color: var(--dim);
transition: color .2s;
}
.nav-links a:hover { color: var(--ink); }
.nav-cta {
background: var(--ink); color: var(--paper);
font-family: var(--sans); font-size: .72rem; font-weight: 700;
letter-spacing: .08em; text-transform: uppercase;
border: none; padding: 10px 24px; border-radius: 2px; cursor: pointer;
transition: background .2s, transform .15s;
}
.nav-cta:hover { background: #2a2a28; transform: translateY(-1px); }
/* ββ HERO ββββββββββββββββββββββββββββββββββββββββββββββββββ */
#hero {
min-height: 100vh;
display: grid; align-items: center;
padding: 140px 56px 80px;
}
.hero-inner {
max-width: 1160px; margin: 0 auto; width: 100%;
display: grid; grid-template-columns: 1fr 1fr;
gap: 72px; align-items: center;
}
.hero-eyebrow {
font-family: var(--mono); font-size: .65rem;
letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
display: flex; align-items: center; gap: 10px;
margin-bottom: 24px;
animation: fadeUp .7s ease both;
}
.hero-eyebrow::before { content: ''; width: 24px; height: 1px; background: var(--mid); }
.hero-headline {
font-family: var(--serif);
font-size: clamp(3rem, 5.2vw, 5.4rem);
font-weight: 900; line-height: .96; letter-spacing: -.03em;
margin-bottom: 24px;
animation: fadeUp .7s .08s ease both;
}
.hero-headline em { font-style: italic; color: var(--dim); }
.hero-sub {
font-size: 1rem; line-height: 1.7; color: var(--dim);
max-width: 380px; margin-bottom: 40px;
animation: fadeUp .7s .16s ease both;
}
.hero-btns { display: flex; gap: 12px; animation: fadeUp .7s .24s ease both; }
.btn-primary {
background: var(--ink); color: var(--paper);
font-family: var(--sans); font-size: .75rem; font-weight: 700;
letter-spacing: .08em; text-transform: uppercase;
border: none; padding: 13px 28px; border-radius: 2px; cursor: pointer;
transition: background .2s, transform .15s;
}
.btn-primary:hover { background: #2a2a28; transform: translateY(-2px); }
.btn-secondary {
background: transparent; color: var(--ink);
font-family: var(--sans); font-size: .75rem; font-weight: 600;
letter-spacing: .08em; text-transform: uppercase;
border: 1.5px solid var(--mid); padding: 13px 28px; border-radius: 2px; cursor: pointer;
transition: border-color .2s, transform .15s;
}
.btn-secondary:hover { border-color: var(--ink); transform: translateY(-2px); }
/* terminal card */
.hero-terminal {
background: var(--ink); border-radius: 8px; overflow: hidden;
box-shadow: 0 32px 64px rgba(0,0,0,.16);
animation: fadeUp .7s .1s ease both;
}
.t-bar {
background: #181816; padding: 13px 18px;
display: flex; align-items: center; gap: 7px;
}
.t-dot { width: 10px; height: 10px; border-radius: 50%; }
.t-dot:nth-child(1) { background: #ff5f57; }
.t-dot:nth-child(2) { background: #febc2e; }
.t-dot:nth-child(3) { background: #28c840; }
.t-lbl { margin-left: auto; font-family: var(--mono); font-size: .6rem; color: #4a4a48; letter-spacing: .08em; }
.t-body { padding: 24px 22px; font-family: var(--mono); font-size: .75rem; line-height: 1.85; color: #b0aba2; }
.tc { color: #484840; }
.tk { color: #7eb8d4; }
.ts { color: #b8d47e; }
.tn { color: #d4b47e; }
.te { color: #d47e7e; }
.tg { color: #7ed4a0; }
.tbadge {
display: inline-block; padding: 2px 8px; border-radius: 2px;
font-size: .58rem; margin-left: 8px;
}
.tbadge.err { background: #d47e7e14; border: 1px solid #d47e7e40; color: #d47e7e; }
.tbadge.ok { background: #7ed4a014; border: 1px solid #7ed4a040; color: #7ed4a0; }
.blink { animation: blink 1.1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
/* hero stats */
.hero-stats {
grid-column: 1 / -1;
display: flex; gap: 52px;
border-top: 1px solid var(--mid); padding-top: 36px;
animation: fadeUp .7s .3s ease both;
}
.stat-num { font-family: var(--serif); font-size: 2.2rem; font-weight: 900; letter-spacing: -.04em; line-height: 1; }
.stat-lbl { font-family: var(--mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-top: 5px; }
/* ββ DIVIDER LINE ββββββββββββββββββββββββββββββββββββββββββ */
.divider {
border: none; border-top: 1px solid var(--mid);
margin: 0;
}
/* ββ SECTIONS ββββββββββββββββββββββββββββββββββββββββββββββ */
section { padding: 96px 56px; }
.si { max-width: 1160px; margin: 0 auto; }
/* section header */
.s-eyebrow {
font-family: var(--mono); font-size: .62rem;
letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
display: flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.s-eyebrow::before { content: ''; width: 18px; height: 1px; background: var(--mid); }
.s-title {
font-family: var(--serif);
font-size: clamp(2rem, 3.6vw, 3.2rem);
font-weight: 900; line-height: 1.05; letter-spacing: -.025em;
margin-bottom: 16px;
}
.s-body {
font-size: .95rem; line-height: 1.72; color: var(--dim);
max-width: 540px;
}
/* dark section overrides */
.dark { background: var(--ink); color: var(--paper); }
.dark .s-eyebrow { color: #666; }
.dark .s-eyebrow::before { background: #333; }
.dark .s-title { color: var(--paper); }
.dark .s-body { color: #999; }
/* ββ REVIEW SECTION ββββββββββββββββββββββββββββββββββββββββ */
.review-grid {
display: grid; grid-template-columns: 1fr 1fr;
gap: 24px; margin-top: 48px;
}
.panel { border: 1px solid #262622; border-radius: 6px; overflow: hidden; }
.panel-head {
padding: 12px 20px; background: #161614;
border-bottom: 1px solid #262622;
display: flex; align-items: center; justify-content: space-between;
}
.panel-label { font-family: var(--mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: #666; }
.panel-meta { font-family: var(--mono); font-size: .6rem; color: #3e3e3a; }
textarea#codeInput {
display: block; width: 100%; height: 260px;
background: transparent; border: none; outline: none; resize: none;
font-family: var(--mono); font-size: .78rem; line-height: 1.7;
color: #c8c3ba; caret-color: #7eb8d4;
padding: 20px;
}
.panel-footer {
display: flex; gap: 10px; align-items: center;
padding: 12px 20px; border-top: 1px solid #262622;
}
.lang-sel {
background: #1a1a18; border: 1px solid #303030; border-radius: 2px;
color: #999; font-family: var(--mono); font-size: .68rem;
padding: 7px 12px; cursor: pointer; outline: none;
}
.run-btn {
margin-left: auto; background: var(--paper); color: var(--ink);
font-family: var(--sans); font-size: .72rem; font-weight: 700;
letter-spacing: .08em; text-transform: uppercase;
border: none; padding: 9px 22px; border-radius: 2px; cursor: pointer;
transition: background .2s, transform .15s;
}
.run-btn:hover { background: #ddd8d0; transform: translateY(-1px); }
.run-btn:disabled { opacity: .5; pointer-events: none; }
/* result area */
.result-body { padding: 20px; min-height: 316px; position: relative; }
.r-empty {
display: flex; flex-direction: column; align-items: center;
justify-content: center; height: 276px; gap: 10px; color: #333;
}
.r-empty p { font-family: var(--mono); font-size: .65rem; color: #3e3e3a; }
.r-loading { display: none; flex-direction: column; align-items: center; justify-content: center; height: 276px; gap: 16px; }
.r-loading.on { display: flex; }
.spinner { width: 20px; height: 20px; border: 2px solid #2a2a28; border-top-color: #888; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner-lbl { font-family: var(--mono); font-size: .65rem; color: #555; }
@keyframes spin { to { transform: rotate(360deg); } }
.r-card { display: none; }
.r-card.on { display: block; }
.bug-header {
display: flex; justify-content: space-between; align-items: center;
margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid #262622;
}
.bug-counter {
font-family: var(--mono); font-size: .65rem; letter-spacing: .08em;
text-transform: uppercase; color: #666;
}
.bug-nav {
display: flex; gap: 8px; align-items: center;
}
.bug-nav-btn {
background: #161614; border: 1px solid #262622; border-radius: 2px;
color: #999; font-family: var(--mono); font-size: .65rem;
padding: 6px 12px; cursor: pointer; transition: all .2s;
}
.bug-nav-btn:hover:not(:disabled) { background: #262622; border-color: #3a3a38; color: #ccc; }
.bug-nav-btn:disabled { opacity: .4; cursor: not-allowed; }
.bug-summary-grid {
display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 8px; margin-bottom: 20px; padding: 12px;
background: #0a0a08; border: 1px solid #262622; border-radius: 4px;
}
.bug-mini-card {
padding: 10px; border-radius: 2px; cursor: pointer; transition: all .2s;
border: 1px solid #262622; font-size: .65rem;
font-family: var(--mono); text-align: center;
}
.bug-mini-card:hover { border-color: #3a3a38; background: #161614; }
.bug-mini-card.current { border-color: #7eb8d4; background: #1a2a3a; }
.r-badge {
display: inline-flex; align-items: center; gap: 6px;
padding: 4px 12px; border-radius: 2px; margin-bottom: 20px;
font-family: var(--mono); font-size: .62rem; font-weight: 600;
letter-spacing: .08em; text-transform: uppercase;
}
.r-badge.sec { background: #d47e7e14; border: 1px solid #d47e7e40; color: #d47e7e; }
.r-badge.lgc { background: #d4c27e14; border: 1px solid #d4c27e40; color: #d4c27e; }
.r-badge.sty { background: #7eb8d414; border: 1px solid #7eb8d440; color: #7eb8d4; }
.r-badge.apr { background: #7ed4a014; border: 1px solid #7ed4a040; color: #7ed4a0; }
.r-field { margin-bottom: 16px; }
.r-field-label {
font-family: var(--mono); font-size: .58rem;
letter-spacing: .12em; text-transform: uppercase; color: #4a4a48;
margin-bottom: 5px;
}
.r-field-value { font-family: var(--mono); font-size: .78rem; color: #c0bbb2; line-height: 1.6; }
.confidence-bar {
display: flex; align-items: center; gap: 8px; margin-top: 4px;
}
.confidence-meter {
width: 100px; height: 6px; background: #262622; border-radius: 2px; overflow: hidden;
}
.confidence-fill {
height: 100%; background: linear-gradient(90deg, #d47e7e, #d4c27e, #7ed4a0);
transition: width .3s;
}
.confidence-pct {
font-size: .65rem; color: #888; font-family: var(--mono);
}
.sev-dots { display: flex; gap: 5px; margin-top: 4px; }
.sd { width: 9px; height: 9px; border-radius: 50%; background: #2a2a28; }
.sd.on { background: #d47e7e; }
.r-fix {
background: #161614; border: 1px solid #262622; border-radius: 4px;
padding: 14px 16px; margin-top: 6px;
font-family: var(--mono); font-size: .73rem; color: #7ed4a0;
white-space: pre-wrap; line-height: 1.65;
}
.export-btn {
display: inline-flex; align-items: center; gap: 6px;
background: #161614; border: 1px solid #262622; border-radius: 2px;
color: #999; font-family: var(--mono); font-size: .65rem;
padding: 6px 12px; cursor: pointer; transition: all .2s; margin-top: 12px;
}
.export-btn:hover { background: #262622; border-color: #3a3a38; color: #ccc; }
/* ββ FEATURES ββββββββββββββββββββββββββββββββββββββββββββββ */
#features { background: var(--surface); }
.feat-grid {
display: grid; grid-template-columns: repeat(3, 1fr);
border: 1px solid var(--mid); border-radius: 6px; overflow: hidden;
margin-top: 48px;
}
.fc {
padding: 36px 30px; position: relative;
border-right: 1px solid var(--mid); border-bottom: 1px solid var(--mid);
transition: background .2s;
}
.fc:hover { background: var(--paper); }
.fc:nth-child(3n) { border-right: none; }
.fc:nth-last-child(-n+3) { border-bottom: none; }
.fc-num {
position: absolute; top: 14px; right: 18px;
font-family: var(--mono); font-size: .56rem; color: var(--mid);
}
.fc-icon {
width: 36px; height: 36px; background: var(--ink); border-radius: 3px;
display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
}
.fc-icon svg { width: 16px; height: 16px; }
.fc-title { font-size: .95rem; font-weight: 700; margin-bottom: 9px; }
.fc-desc { font-size: .88rem; line-height: 1.65; color: var(--dim); }
/* ββ API TABLE βββββββββββββββββββββββββββββββββββββββββββββ */
.ep-table { margin-top: 44px; width: 100%; border-collapse: collapse; }
.ep-table th {
text-align: left;
font-family: var(--mono); font-size: .6rem; letter-spacing: .12em;
text-transform: uppercase; color: var(--dim);
padding: 10px 16px; border-bottom: 1.5px solid var(--mid);
background: var(--surface);
}
.ep-table td {
padding: 15px 16px; border-bottom: 1px solid #ddd8d0; vertical-align: top;
}
.ep-table tr:last-child td { border-bottom: none; }
.ep-table tr:hover td { background: rgba(0,0,0,.018); }
.method {
display: inline-block; padding: 3px 9px; border-radius: 2px;
font-family: var(--mono); font-size: .62rem; font-weight: 600;
}
.mget { background: #7eb8d410; border: 1px solid #7eb8d440; color: #3a7fa0; }
.mpost { background: #7ed4a010; border: 1px solid #7ed4a040; color: #2a8050; }
.ep-route { font-family: var(--mono); font-size: .78rem; font-weight: 500; color: var(--ink); }
.ep-desc { font-size: .9rem; color: var(--dim); }
.ep-param { font-family: var(--mono); font-size: .68rem; color: var(--dim); }
/* ββ TRAINING ββββββββββββββββββββββββββββββββββββββββββββββ */
.train-layout {
display: grid; grid-template-columns: 1fr 1.5fr;
gap: 56px; align-items: start; margin-top: 48px;
}
.ctrl-label {
font-family: var(--mono); font-size: .62rem; letter-spacing: .1em;
text-transform: uppercase; color: #666; display: block; margin-bottom: 10px;
}
.ep-display {
font-family: var(--serif); font-size: 3.4rem; font-weight: 900;
letter-spacing: -.04em; line-height: 1; margin-bottom: 12px;
}
input[type=range] { width: 100%; accent-color: var(--paper); }
.train-btn {
display: block; width: 100%; margin-top: 20px;
background: var(--paper); color: var(--ink);
font-family: var(--sans); font-size: .75rem; font-weight: 700;
letter-spacing: .08em; text-transform: uppercase;
border: none; padding: 14px; border-radius: 2px; cursor: pointer;
transition: background .2s, transform .15s;
}
.train-btn:hover { background: #ddd8d0; transform: translateY(-1px); }
.train-status { margin-top: 12px; font-family: var(--mono); font-size: .68rem; color: #555; min-height: 20px; }
.rew-card { border: 1px solid #262622; border-radius: 6px; overflow: hidden; }
.rew-head {
padding: 14px 20px; background: #161614; border-bottom: 1px solid #262622;
font-family: var(--mono); font-size: .62rem; letter-spacing: .1em;
text-transform: uppercase; color: #666;
}
.rew-list { padding: 4px 0; }
.rew-row {
display: flex; justify-content: space-between; align-items: center;
padding: 12px 20px;
font-family: var(--mono); font-size: .75rem; color: #888;
border-bottom: 1px solid #1c1c1a;
}
.rew-row:last-child { border-bottom: none; }
.rv { font-weight: 500; }
.rv.pos { color: #7ed4a0; }
.rv.neg { color: #d47e7e; }
/* ββ FOOTER ββββββββββββββββββββββββββββββββββββββββββββββββ */
footer {
background: var(--ink); border-top: 1px solid #1c1c1a;
padding: 44px 56px 32px;
}
.footer-inner {
max-width: 1160px; margin: 0 auto;
display: flex; align-items: center; justify-content: space-between;
}
.f-logo { font-family: var(--serif); font-size: 1.4rem; font-weight: 900; color: var(--paper); letter-spacing: -.02em; }
.f-copy { font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: #4a4a48; }
.f-links { display: flex; gap: 24px; list-style: none; }
.f-links a { font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; color: #4a4a48; transition: color .2s; }
.f-links a:hover { color: var(--mid); }
/* ββ ANIMATIONS ββββββββββββββββββββββββββββββββββββββββββββ */
@keyframes fadeUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .65s ease, transform .65s ease; }
.reveal.v { opacity: 1; transform: none; }
/* ββ SCROLLBAR βββββββββββββββββββββββββββββββββββββββββββββ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--mid); border-radius: 2px; }
/* ββ RESPONSIVE ββββββββββββββββββββββββββββββββββββββββββββ */
@media (max-width: 860px) {
nav { padding: 16px 24px; }
.nav-links { display: none; }
section { padding: 72px 24px; }
#hero { padding: 120px 24px 64px; }
.hero-inner { grid-template-columns: 1fr; gap: 40px; }
.hero-stats { flex-wrap: wrap; gap: 28px; }
.review-grid { grid-template-columns: 1fr; }
.feat-grid { grid-template-columns: 1fr; }
.fc { border-right: none; }
.train-layout { grid-template-columns: 1fr; }
.footer-inner { flex-direction: column; gap: 20px; text-align: center; }
.f-links { display: none; }
}
</style>
</head>
<body>
<!-- ββ NAV ββββββββββββββββββββββββββββββββββββββββββββββββ -->
<nav>
<div class="nav-logo">CodeBug<sup>Ξ²</sup></div>
<ul class="nav-links">
<li><a href="#review">Review</a></li>
<li><a href="#features">Features</a></li>
<li><a href="#api">API</a></li>
<li><a href="#train">Training</a></li>
</ul>
<button class="nav-cta" onclick="scroll2('review')">Try Now β</button>
</nav>
<!-- ββ HERO βββββββββββββββββββββββββββββββββββββββββββββββ -->
<section id="hero">
<div class="hero-inner">
<div>
<div class="hero-eyebrow">AI-Powered Code Review</div>
<h1 class="hero-headline">Bugs Found.<br><em>Before They</em><br>Ship.</h1>
<p class="hero-sub">CodeBug combines Claude + GPT-4o to catch security flaws, logic errors, and style issues β with a reinforcement-learning grader that improves over time.</p>
<div class="hero-btns">
<button class="btn-primary" onclick="scroll2('review')">Review Code β</button>
<button class="btn-secondary" onclick="scroll2('api')">View API</button>
</div>
</div>
<div class="hero-terminal">
<div class="t-bar">
<div class="t-dot"></div>
<div class="t-dot"></div>
<div class="t-dot"></div>
<span class="t-lbl">codebug β review</span>
</div>
<div class="t-body">
<span class="tc"># POST /api/review</span>
<span class="tc">ββββββββββββββββββββββ</span>
<span class="tk">language</span> <span class="ts">"python"</span>
<span class="tk">analyzing</span> <span class="tc">get_user.py β¦</span>
<span class="tk">type</span> <span class="te">bug</span><span class="tbadge err">security</span>
<span class="tk">severity</span> <span class="te">5 / 5</span>
<span class="tk">line</span> <span class="tn">14</span>
<span class="tk">comment</span> SQL injection via
f-string interpolation
<span class="tk">fix</span>
<span class="ts">cursor.execute(</span>
<span class="ts"> "SELECT * FROM users</span>
<span class="ts"> WHERE id = ?", (uid,))</span>
<span class="tk">reward</span> <span class="tg">+43</span><span class="tbadge ok">correct</span>
<span class="blink">β</span>
</div>
</div>
<div class="hero-stats">
<div><div class="stat-num">15+</div><div class="stat-lbl">Bug Patterns</div></div>
<div><div class="stat-num">3</div><div class="stat-lbl">Languages</div></div>
<div><div class="stat-num">2</div><div class="stat-lbl">LLM Backends</div></div>
<div><div class="stat-num">RL</div><div class="stat-lbl">Self-Improving</div></div>
</div>
</div>
</section>
<hr class="divider" />
<!-- ββ LIVE REVIEW βββββββββββββββββββββββββββββββββββββββββ -->
<section id="review" class="dark">
<div class="si">
<div class="s-eyebrow">Live Demo</div>
<h2 class="s-title">Review Your Code.</h2>
<p class="s-body">Paste any snippet. CodeBug calls <code style="font-family:var(--mono)">POST /api/review</code> and returns a structured result β type, severity, comment, and a fix snippet.</p>
<div class="review-grid reveal">
<!-- input panel -->
<div class="panel">
<div class="panel-head">
<span class="panel-label">Input</span>
<span class="panel-meta">max 5 000 chars</span>
</div>
<textarea id="codeInput" placeholder="# Paste your code hereβ¦
# e.g.:
def get_user(uid):
q = f"SELECT * FROM users WHERE id={uid}"
cursor.execute(q)
return cursor.fetchone()"></textarea>
<div class="panel-footer">
<select class="lang-sel" id="langSel" required>
<option value="">β Select Language β</option>
<option value="python">Python</option>
<option value="javascript">JavaScript</option>
<option value="typescript">TypeScript</option>
<option value="java">Java</option>
<option value="go">Go</option>
<option value="cpp">C++</option>
</select>
<button class="run-btn" id="runBtn" onclick="doReview()">
<span id="runLbl">Analyze β</span>
</button>
</div>
</div>
<!-- output panel -->
<div class="panel">
<div class="panel-head">
<span class="panel-label">Result</span>
<span class="panel-meta" id="rTs"></span>
</div>
<div class="result-body">
<div class="r-empty" id="rEmpty">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="#333" stroke-width="1.2">
<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35M11 8v6M8 11h6"/>
</svg>
<p>Awaiting analysisβ¦</p>
</div>
<div class="r-loading" id="rLoading">
<div class="spinner"></div>
<span class="spinner-lbl">Calling Claude APIβ¦</span>
</div>
<div class="r-card" id="rCard">
<div class="bug-header">
<div id="rBadge" class="r-badge"></div>
<div class="bug-nav">
<button class="bug-nav-btn" id="prevBtn" onclick="prevBug()">β Prev</button>
<span class="bug-counter" id="bugCounter"></span>
<button class="bug-nav-btn" id="nextBtn" onclick="nextBug()">Next β</button>
</div>
</div>
<div id="bugSummary" class="bug-summary-grid" style="display: none;"></div>
<div class="r-field">
<div class="r-field-label">Category</div>
<div class="r-field-value" id="rCat">β</div>
</div>
<div class="r-field">
<div class="r-field-label">Severity</div>
<div class="sev-dots" id="rSev"></div>
</div>
<div class="r-field">
<div class="r-field-label">Confidence</div>
<div class="confidence-bar">
<div class="confidence-meter">
<div class="confidence-fill" id="rConfidence" style="width: 0%"></div>
</div>
<span class="confidence-pct" id="rConfidencePct">β</span>
</div>
</div>
<div class="r-field">
<div class="r-field-label">Line Hint</div>
<div class="r-field-value" id="rLine">β</div>
</div>
<div class="r-field">
<div class="r-field-label">Comment</div>
<div class="r-field-value" id="rComment">β</div>
</div>
<div class="r-field">
<div class="r-field-label">Suggested Fix</div>
<pre class="r-fix" id="rFix"></pre>
<button class="export-btn" onclick="exportBugReport()">π₯ Export to JSON</button>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- ββ FEATURES βββββββββββββββββββββββββββββββββββββββββββ -->
<section id="features">
<div class="si">
<div class="s-eyebrow">Capabilities</div>
<h2 class="s-title">Every Layer,<br>Covered.</h2>
<div class="feat-grid reveal">
<div class="fc">
<span class="fc-num">01</span>
<div class="fc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
</svg>
</div>
<div class="fc-title">Security Detection</div>
<p class="fc-desc">Catches SQL injection, hardcoded secrets, and plain-text passwords β each severity-scored from 1 to 5.</p>
</div>
<div class="fc">
<span class="fc-num">02</span>
<div class="fc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">
<circle cx="12" cy="12" r="10"/><path d="M12 8v4l3 3"/>
</svg>
</div>
<div class="fc-title">Logic Analysis</div>
<p class="fc-desc">Off-by-one errors, wrong comparisons, missing null checks, and divide-by-zero traps across all supported languages.</p>
</div>
<div class="fc">
<span class="fc-num">03</span>
<div class="fc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">
<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>
</svg>
</div>
<div class="fc-title">Multi-Language</div>
<p class="fc-desc">Python, JavaScript, and Java β each with language-idiomatic bug patterns in the bug bank.</p>
</div>
<div class="fc">
<span class="fc-num">04</span>
<div class="fc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
</svg>
</div>
<div class="fc-title">Dual LLM Fallback</div>
<p class="fc-desc">Claude Haiku runs first. Any exception silently falls back to GPT-4o-mini with no disruption to the API response.</p>
</div>
<div class="fc">
<span class="fc-num">05</span>
<div class="fc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">
<line x1="18" y1="20" x2="18" y2="10"/>
<line x1="12" y1="20" x2="12" y2="4"/>
<line x1="6" y1="20" x2="6" y2="14"/>
</svg>
</div>
<div class="fc-title">RL Reward Grading</div>
<p class="fc-desc">Every review earns a reward score. +25 for critical security catches, β25 for missed criticals. The model learns.</p>
</div>
<div class="fc">
<span class="fc-num">06</span>
<div class="fc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">
<ellipse cx="12" cy="5" rx="9" ry="3"/>
<path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"/>
<path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"/>
</svg>
</div>
<div class="fc-title">Review History</div>
<p class="fc-desc">All reviews and training runs stored in SQLite. Query via /api/history and /api/stats endpoints.</p>
</div>
</div>
</div>
</section>
<!-- ββ API REFERENCE βββββββββββββββββββββββββββββββββββββββ -->
<section id="api">
<div class="si">
<div class="s-eyebrow">REST API</div>
<h2 class="s-title">Five Endpoints.<br>Zero Config.</h2>
<p class="s-body">Rate-limited to 20 req/min per IP. All responses are JSON. Start the server with <code style="font-family:var(--mono)">python app.py</code>.</p>
<table class="ep-table reveal">
<thead>
<tr>
<th>Method</th>
<th>Route</th>
<th>Description</th>
<th>Params</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="method mpost">POST</span></td>
<td class="ep-route">/api/review</td>
<td class="ep-desc">Submit code for AI review. Returns type, category, severity, comment, and fix snippet.</td>
<td class="ep-param">code, language?</td>
</tr>
<tr>
<td><span class="method mpost">POST</span></td>
<td class="ep-route">/api/train</td>
<td class="ep-desc">Run N RL training episodes. Auto-saves checkpoint. Returns full stats dict.</td>
<td class="ep-param">episodes? (β€ 100)</td>
</tr>
<tr>
<td><span class="method mget">GET</span></td>
<td class="ep-route">/api/history</td>
<td class="ep-desc">Returns paginated list of past reviews from the SQLite database.</td>
<td class="ep-param">limit? (β€ 200)</td>
</tr>
<tr>
<td><span class="method mget">GET</span></td>
<td class="ep-route">/api/stats</td>
<td class="ep-desc">Aggregate stats: training runs, review counts, average reward, top bug categories.</td>
<td class="ep-param">β</td>
</tr>
<tr>
<td><span class="method mget">GET</span></td>
<td class="ep-route">/api/health</td>
<td class="ep-desc">Health check. Returns model name and DB connection status.</td>
<td class="ep-param">β</td>
</tr>
</tbody>
</table>
</div>
</section>
<!-- ββ TRAINING ββββββββββββββββββββββββββββββββββββββββββββ -->
<section id="train" class="dark">
<div class="si">
<div class="s-eyebrow">Reinforcement Learning</div>
<h2 class="s-title">Train the<br>Reviewer.</h2>
<p class="s-body">Run RL episodes against the bug bank. The grader rewards precision and penalises misses. Checkpoints auto-save and are fully resumable.</p>
<div class="train-layout reveal">
<div>
<label class="ctrl-label">Episodes to run</label>
<div class="ep-display" id="epDisplay">20</div>
<input type="range" min="1" max="100" value="20" id="epRange"
oninput="document.getElementById('epDisplay').textContent = this.value" />
<button class="train-btn" onclick="doTrain()">Run Training β</button>
<div class="train-status" id="trainStatus"></div>
</div>
<div class="rew-card">
<div class="rew-head">Reward Schedule</div>
<div class="rew-list">
<div class="rew-row"><span>Correct β Security</span> <span class="rv pos">+25</span></div>
<div class="rew-row"><span>Correct β Logic</span> <span class="rv pos">+15</span></div>
<div class="rew-row"><span>Correct β Other</span> <span class="rv pos">+10</span></div>
<div class="rew-row"><span>Correct β Approve</span> <span class="rv pos">+5</span></div>
<div class="rew-row"><span>Severity exact match</span><span class="rv pos">+5</span></div>
<div class="rew-row"><span>Detailed comment</span> <span class="rv pos">+5</span></div>
<div class="rew-row"><span>Non-empty fix field</span> <span class="rv pos">+3</span></div>
<div class="rew-row"><span>Line hint provided</span> <span class="rv pos">+3</span></div>
<div class="rew-row"><span>False positive</span> <span class="rv neg">β10</span></div>
<div class="rew-row"><span>Missed critical bug</span> <span class="rv neg">β25</span></div>
<div class="rew-row"><span>Missed high severity</span><span class="rv neg">β20</span></div>
</div>
</div>
</div>
</div>
</section>
<!-- ββ FOOTER ββββββββββββββββββββββββββββββββββββββββββββββ -->
<footer>
<div class="footer-inner">
<div class="f-logo">CodeBug</div>
<span class="f-copy">Β© 2025 β Flask Β· Claude Β· SQLite</span>
<ul class="f-links">
<li><a href="#review">Review</a></li>
<li><a href="#api">API</a></li>
<li><a href="#train">Train</a></li>
</ul>
</div>
</footer>
<script>
/* scroll helper */
function scroll2(id) {
document.getElementById(id).scrollIntoView({ behavior: 'smooth' });
}
/* reveal on scroll */
const revealObs = new IntersectionObserver(entries => {
entries.forEach(e => {
if (e.isIntersecting) { e.target.classList.add('v'); revealObs.unobserve(e.target); }
});
}, { threshold: 0.1 });
document.querySelectorAll('.reveal').forEach(el => revealObs.observe(el));
/* ββ REVIEW βββββββββββββββββββββββββββββββββββββββββββββββ */
let allBugs = [];
let currentBugIndex = 0;
function prevBug() {
if (currentBugIndex > 0) {
currentBugIndex--;
displayBug(allBugs[currentBugIndex]);
updateBugNav();
}
}
function nextBug() {
if (currentBugIndex < allBugs.length - 1) {
currentBugIndex++;
displayBug(allBugs[currentBugIndex]);
updateBugNav();
}
}
function updateBugNav() {
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
const counter = document.getElementById('bugCounter');
prevBtn.disabled = currentBugIndex === 0;
nextBtn.disabled = currentBugIndex >= allBugs.length - 1;
counter.textContent = `Bug ${currentBugIndex + 1} / ${allBugs.length}`;
}
function displayBug(bug) {
const badgeCls = bug.category === 'security' ? 'sec'
: bug.category === 'logic' ? 'lgc'
: bug.type === 'approve' ? 'apr' : 'sty';
const badge = document.getElementById('rBadge');
badge.className = 'r-badge ' + badgeCls;
if (bug.type === 'approve') {
badge.textContent = 'β Approved';
} else {
badge.textContent = 'β ' + (bug.category || bug.type);
}
document.getElementById('rCat').textContent = bug.category || bug.type || 'β';
document.getElementById('rLine').textContent = bug.line_hint ? 'Line ' + bug.line_hint : 'Not specified';
document.getElementById('rComment').textContent = bug.comment || 'β';
// Display confidence with progress bar
const confidence = bug.confidence || 0.5;
const confPercent = Math.round(confidence * 100);
document.getElementById('rConfidence').style.width = (confidence * 100) + '%';
document.getElementById('rConfidencePct').textContent = confPercent + '%';
const fixString = (bug.fix && bug.fix.fixed_code) ? bug.fix.fixed_code : bug.fix;
document.getElementById('rFix').textContent = fixString || (bug.type === 'approve' ? '(no fix required)' : 'β');
const dotsEl = document.getElementById('rSev');
dotsEl.innerHTML = '';
for (let i = 1; i <= 5; i++) {
const dot = document.createElement('div');
dot.className = 'sd' + (i <= (bug.severity || 0) ? ' on' : '');
dotsEl.appendChild(dot);
}
}
async function doReview() {
const code = document.getElementById('codeInput').value.trim();
const lang = document.getElementById('langSel').value;
const btn = document.getElementById('runBtn');
if (!code) { showFlash('Paste some code first.'); return; }
if (!lang) { showFlash('Please select a language.'); return; }
if (code.length > 5000) { showFlash('Code exceeds 5 000 characters.'); return; }
btn.disabled = true;
document.getElementById('runLbl').textContent = 'Analyzingβ¦';
document.getElementById('rEmpty').style.display = 'none';
document.getElementById('rCard').classList.remove('on');
document.getElementById('rLoading').classList.add('on');
try {
const res = await fetch('/api/review', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ code, language: lang })
});
if (!res.ok) {
const errData = await res.json().catch(() => ({}));
throw new Error(errData.detail || errData.error || `API error: ${res.status}`);
}
const data = await res.json();
console.log('β Real API response received:', data);
renderResult(data);
} catch (err) {
console.error('β API call failed:', err.message);
console.warn('Using fallback local analysis...');
const mockData = mockReview(code, lang);
console.log('Fallback result:', mockData);
renderResult(mockData);
} finally {
btn.disabled = false;
document.getElementById('runLbl').textContent = 'Analyze β';
document.getElementById('rLoading').classList.remove('on');
}
}
function mockReview(code, lang) {
// Comprehensive pattern-based bug detection
// === SECURITY BUGS (Highest Priority) ===
if (/f["'`].*?\$\{.*?\}|f["'`].*?{.*?}/.test(code) && /(select|insert|delete|update|from|where)/i.test(code)) {
return {
type: 'bug',
category: 'security',
severity: 5,
line_hint: 3,
comment: 'SQL injection: User input in f-string flows directly to database query.',
fix: 'Use parameterized queries: cursor.execute("SELECT * FROM users WHERE id = ?", (uid,))'
};
}
if (/(password|passwd|pwd)\s*[:=]\s*["'].*["']|".*password.*":\s*".*"/i.test(code)) {
return {
type: 'bug',
category: 'security',
severity: 5,
line_hint: 2,
comment: 'Hardcoded password detected. Never store credentials in source code.',
fix: 'Use environment variables: password = os.getenv("DB_PASSWORD")'
};
}
if (/(api_key|apikey|secret|token|private|private_key|secret_key)\s*[:=]\s*["'][a-zA-Z0-9]{8,}["']/i.test(code)) {
return {
type: 'bug',
category: 'security',
severity: 4,
line_hint: 1,
comment: 'Hardcoded API key/secret detected. Move to environment variables.',
fix: 'api_key = os.getenv("API_KEY")\nif not api_key:\n raise ValueError("API_KEY not set")'
};
}
if (/eval\s*\(|exec\s*\(|pickle\.load|yaml\.load\s*\(|\$\{\s*.*?\s*\}/.test(code)) {
return {
type: 'bug',
category: 'security',
severity: 5,
line_hint: 2,
comment: 'Arbitrary code execution vulnerability. eval() and exec() are dangerous.',
fix: 'Use safe alternatives: json.loads(), ast.literal_eval(), or parameterized logic.'
};
}
// === LOGIC BUGS ===
if (/(while\s+true|for\s+\(\s*;\s*;\s*\)|while\s*\(.*\))/.test(code) && !/(break|return|exit)/.test(code)) {
return {
type: 'bug',
category: 'logic',
severity: 3,
line_hint: 2,
comment: 'Infinite loop detected. Loop never breaks or returns.',
fix: 'Add break condition: while condition: {...; break}'
};
}
if (/range\s*\(\s*len\s*\(\s*.*?\s*\)\s*-\s*1\s*\)/.test(code)) {
return {
type: 'bug',
category: 'logic',
severity: 3,
line_hint: 2,
comment: 'Off-by-one error: range(len(x) - 1) skips the last element.',
fix: 'Use: for i in range(len(items)): or simply: for item in items:'
};
}
if (/if\s+(len\s*\(\s*\w+\s*\)\s*[>!=<]=?\s*0|len\s*\(\s*\w+\s*\)\s*!=\s*0)/.test(code)) {
return {
type: 'bug',
category: 'logic',
severity: 2,
line_hint: 1,
comment: 'Redundant length check. Empty sequences are falsy in Python.',
fix: 'Use: if items: instead of if len(items) != 0:'
};
}
if (/===|!==/.test(code) && lang === 'javascript') {
// This is actually GOOD in JS, so check for == instead
if (/[^=!=]\s*==\s*[^=]|[^=]\s*!=\s*[^=]/.test(code)) {
return {
type: 'bug',
category: 'logic',
severity: 2,
line_hint: 3,
comment: 'Use strict equality (===) instead of ==. Subject to type coercion bugs.',
fix: 'Replace == with === and != with !=='
};
}
}
// === STYLE/BEST PRACTICES ===
if (/var\s+\w+\s*=/.test(code) && lang === 'javascript') {
return {
type: 'bug',
category: 'style',
severity: 2,
line_hint: 1,
comment: 'Use const/let instead of var. var has scope issues.',
fix: 'Replace var with const (or let if reassignment needed)'
};
}
if (/print\s*\(/.test(code) && lang === 'python') {
// Check for simple print, could suggest logging
if (!/import logging|logger\./. test(code)) {
return {
type: 'approve',
category: 'style',
severity: 1,
line_hint: null,
comment: 'Consider using logging module for production code instead of print().',
fix: 'import logging\nlogging.info("message")'
};
}
}
// === DEFAULT: NO BUGS ===
return {
type: 'approve',
category: 'style',
severity: 1,
line_hint: null,
comment: 'No obvious bugs detected. Code looks clean.',
fix: '',
confidence: 1.0
};
}
function renderResult(d) {
// Handle both old (single bug) and new (multiple bugs) formats
allBugs = [];
currentBugIndex = 0;
if (d.bugs && d.bugs.length > 0) {
// New format: multiple bugs detected
allBugs = d.bugs;
} else if (d.primary_bug) {
// Fallback: single primary bug
allBugs = [d.primary_bug];
} else if (d.ai_action) {
// Old format: single bug response
allBugs = [d.ai_action];
} else {
// Direct bug object (from mockReview)
allBugs = [d];
}
// Hide summary grid and update main display
const summaryGrid = document.getElementById('bugSummary');
summaryGrid.style.display = allBugs.length > 1 ? 'grid' : 'none';
if (allBugs.length > 1) {
// Build summary grid for quick navigation
summaryGrid.innerHTML = '';
allBugs.forEach((bug, idx) => {
const miniCard = document.createElement('div');
miniCard.className = 'bug-mini-card' + (idx === 0 ? ' current' : '');
const sevText = bug.severity ? 'β'.repeat(bug.severity) : 'β';
miniCard.innerHTML = `<div>${bug.category || 'other'}</div><div style="opacity:.6;margin-top:2px;">${sevText}</div>`;
miniCard.onclick = () => {
currentBugIndex = idx;
displayBug(allBugs[idx]);
updateBugNav();
// Update all mini cards
document.querySelectorAll('.bug-mini-card').forEach((c, i) => {
c.classList.toggle('current', i === idx);
});
};
summaryGrid.appendChild(miniCard);
});
}
// Display first bug
displayBug(allBugs[0]);
updateBugNav();
document.getElementById('rTs').textContent = new Date().toLocaleTimeString();
document.getElementById('rCard').classList.add('on');
}
function showFlash(msg) {
const el = document.getElementById('rEmpty');
el.style.display = 'flex';
el.innerHTML = `
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#d47e7e" stroke-width="1.4">
<circle cx="12" cy="12" r="10"/>
<line x1="12" y1="8" x2="12" y2="12"/>
<line x1="12" y1="16" x2="12.01" y2="16"/>
</svg>
<p style="color:#d47e7e">${msg}</p>`;
}
/* Export bug report as JSON */
function exportBugReport() {
if (allBugs.length === 0) {
showFlash('No bugs to export. Run analysis first.');
return;
}
const code = document.getElementById('codeInput').value;
const lang = document.getElementById('langSel').value;
const report = {
timestamp: new Date().toISOString(),
language: lang,
code_length: code.length,
bugs_found: allBugs.length,
bugs: allBugs,
export_version: "2.0"
};
const dataStr = JSON.stringify(report, null, 2);
const dataBlob = new Blob([dataStr], { type: 'application/json' });
const url = URL.createObjectURL(dataBlob);
const link = document.createElement('a');
link.href = url;
link.download = `codebug-report-${new Date().toISOString().slice(0,10)}.json`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
showFlash('β Report exported successfully!');
}
/* ββ TRAINING βββββββββββββββββββββββββββββββββββββββββββββ */
async function doTrain() {
const ep = parseInt(document.getElementById('epRange').value);
const btn = document.querySelector('.train-btn');
const st = document.getElementById('trainStatus');
btn.disabled = true;
btn.textContent = 'Runningβ¦';
st.textContent = `Starting ${ep} episodesβ¦`;
st.style.color = '#555';
try {
const res = await fetch('/api/train', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ episodes: ep })
});
const data = await res.json();
if (!res.ok) throw new Error(data.error);
st.textContent = `β Done β reward: ${(data.total_reward || 0).toFixed(1)}, accuracy: ${((data.accuracy || 0) * 100).toFixed(0)}%`;
st.style.color = '#7ed4a0';
} catch {
st.textContent = 'Connect Flask backend to run real training.';
st.style.color = '#555';
} finally {
btn.disabled = false;
btn.textContent = 'Run Training β';
}
}
/* Cmd/Ctrl+Enter to run review */
document.addEventListener('keydown', e => {
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') doReview();
});
</script>
</body>
</html>
|