Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion jcode-intelligence/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ src/main/resources/application.properties

# Environment variables
.env
.env.*
.env.*

#testing logs
*.log
build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import com.shravan.jcode_intelligence.cli.util.Ansi;

public class ColorPalette {
public static final String PRIMARY = Ansi.CYAN;
public static final String PRIMARY = Ansi.MAGENTA;
public static final String SECONDARY = Ansi.BLUE;
public static final String SUCCESS = Ansi.GREEN;
public static final String WARNING = Ansi.YELLOW;
public static final String ERROR = Ansi.RED;
public static final String TEXT = Ansi.WHITE;
public static final String MUTED = Ansi.GRAY;
public static final String ACCENT = Ansi.BOLD + Ansi.CYAN;
public static final String ACCENT = Ansi.BOLD + Ansi.MAGENTA;
public static final String RESET = Ansi.RESET;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,33 @@
import com.shravan.jcode_intelligence.cli.util.TerminalUtils;

public class ConsoleUI {
private static final String[] ASTRA_LOGO = {
"________ ________ _________ ________ ________ ",
"|\\ __ \\|\\ ____\\|\\___ ___\\\\ __ \\|\\ __ \\ ",
"\\ \\ \\|\\ \\ \\ \\___|\\|___ \\ \\_\\ \\ \\|\\ \\ \\ \\|\\ \\ ",
" \\ \\ __ \\ \\_____ \\ \\ \\ \\ \\ _ _\\ \\ __ \\ ",
" \\ \\ \\ \\ \\|____|\\ \\ \\ \\ \\ \\ \\ \\\\ \\\\ \\ \\ \\ \\ ",
" \\ \\__\\ \\__\\____\\_\\ \\ \\ \\ \\ \\ \\__\\\\ _\\\\ \\__\\ \\__\\",
" \\|__|\\|__|\\_________\\ \\|__| \\|__|\\|__|\\|__|\\|__|",
" \\|_________| "
};
private static final String ANSI_M = "\u001b[35m";
private static final String ANSI_BM = "\u001b[95m";
private static final String ANSI_G = "\u001b[37m";
private static final String ANSI_BGM = "\u001b[45m";
private static final String ANSI_RESET = "\u001b[0m";

private static final String ASTRA_LOGO_TEMPLATE = """
{M} {R}{G} {R}{M} ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄{R}{G} {R}{M} ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄{R}{G} {R}{M}▄▄▄▄▄▄▄▄▄▄▄▄▄▄{R}{MM}▀{R}{M}▄ {R}{G} {R}{M} {R}
{M} ▀▓{R}{MM}▄▄▄▄{R}{M}█▄▄ {R}{G} {R}{M} ▄{R}{MM}▄██▓█▀▀▀▀▀▓███░{R}{MM}░▓{R}{G} {R}{M}▀{R}{MM}▓{R}{MM}▒▓█▀▓▓████{R}{BM}█{R}{MM}▓▀▀▀▓█▀{R}{MM}▄{R}{G} {R}{M}█{R}{MM}▀███ {R}{M} ░▀{R}{MM}▒▓█▒{R}{M}█{R}{MM}▐{R}{M} {R}{G} {R}{M} ▀▓{R}{MM}▄▄▄▄{R}{M}█▄▄ {R}
{M} ░█{R}{MM}██▌▀▀▀█▄{R}{M}▄ {R}{G} {R}{M} ░{R}{MM}▒{R}{MM}▓▓▒▓{R}{M}█▀ ░{R}{MM}░▓██▒{R}{MM}▓{R}{M}▌{R}{G} {R}{M} ▀{R}{MM}░▄{R}{M}░{R}{MM}▒▓▓{R}{BM}███{R}{MM}░{R}{MM}▄{R}{M}▀▒{R}{MM}░{R}{BM}▓{R}{M}█{R}{MM}▄{R}{M} {R}{G} {R}{M}▓█{R}{MM}▓▓▓{R}{M}█ {R}{MM}▄▓▓▀{R}{MM}▄{R}{M}▀ {R}{G} {R}{M} ░█{R}{MM}██▌▀▀▀█▄{R}{M}▄ {R}
{M} ░▐{R}{MM}▐██{R}{M}█ ▀{R}{MM} {R}{MM}██{R}{M}▌ {R}{G} {R}{M} █{R}{MM} {R}{MM}▒▒▒{R}{M}█▌ ▀▀▀▀▀ {R}{G} {R}{M} ▀ {R}{MM}░▓▓▓▓░{R}{MM}▐{R}{M} ░{R}{MM}▄▄{R}{M}▀ {R}{G} {R}{M}▒█{R}{MM}▄{R}{M}▀{R}{MM}▀{R}{MM}▄▄█▓▓▒{R}{MM}▄{R}{M}▀ {R}{G} {R}{M} ░▐{R}{MM}▐██{R}{M}█ ▀{R}{MM} {R}{MM}██{R}{M}▌ {R}
{M} ░█{R}{MM}▓▓░{R}{M}▌ ▓{R}{MM}▓▓▓{R}{M}▌ {R}{G} {R}{M} ▓{R}{MM} {R}{MM}░░▒░{R}{M}▌ ▄▄▄▄▄▄ {R}{G} {R}{M} {R}{MM}░{R}{MM}▒▒▒▒{R}{M}█{R}{MM}▓{R}{M} {R}{G} {R}{M}░▓░{R}{MM}▄▓{R}{BM}▀{R}{M}▀▀{R}{MM}▀▓▒░{R}{M}▓▄ {R}{G} {R}{M} ░█{R}{MM}▓▓░{R}{M}▌ ▓{R}{MM}▓▓▓{R}{M}▌ {R}
{M} ░▐{R}{MM}░▒▒ {R}{M} ▄▄{R}{MM}▄▓▒▒▒{R}{M}▄▄ {R}{G} {R}{M} {R}{BM}▄{R}{MM} ░░{R}{M}▀{R}{MM}▀{R}{MM}▄█▀▀▀▀■ ░░{R}{M}▄▀▄{R}{G} {R}{M} {R}{MM}▓{R}{MM}░░░░{R}{M}█▓ {R}{G} {R}{M}░▓▌{R}{MM}▒{R}{BM}▌{R}{MM} {R}{M} ░█{R}{MM}▓▒░ {R}{M}▌ {R}{G} {R}{M} ░▐{R}{MM}░▒▒ {R}{M} ▄▄{R}{MM}▄▓▒▒▒{R}{M}▄▄ {R}
{M}▀▄█{R}{MM}░░{R}{MM}░{R}{M}▀▄█{R}{MM}▀{R}{MM}▄{R}{M}▀▓█{R}{MM}░░░{R}{M}▄ {R}{G} {R}{BM}▀{R}{M}█▄{R}{MM}▄{R}{MM}░{R}{M}▓{R}{MM}▌{R}{MM}▓░{R}{MM}▄{R}{M}▀ ▀░▄▀{R}{MM} {R}{MM}░{R}{M}█▌{R}{MM}▓{R}{G} {R}{M} ▓{R}{MM}░░░░{R}{M}█{R}{MM}▓{R}{M} {R}{G} {R}{M}▒█▒░{R}{MM}▀{R}{BM}▄{R}{M} ▒{R}{MM} {R}{MM}░░░ {R}{M}▌ {R}{G} {R}{M}▀▄█{R}{MM}░░{R}{MM}░{R}{M}▀▄█{R}{MM}▀{R}{MM}▄{R}{M}▀▓█{R}{MM}░░░{R}{M}▄ {R}
{M}░▓█{R}{MM}░{R}{M}▀{R}{MM}▄▀{R}{M}▀▀ ░{R}{MM}░{R}{M}████ {R}{G} {R}{M} ▀▀{R}{MM}▄{R}{M}▄▄{R}{MM}▀{R}{MM}░{R}{MM}▐{R}{M} ░{R}{MM}█▀▌ {R}{M}▌{R}{MM}▒{R}{G} {R}{M} ▒{R}{MM}▌{R}{MM}░░░{R}{M}█{R}{MM}▐{R}{M} {R}{G} {R}{M}▓{R}{MM}▀▀░{R}{M}▄▒▀ ░▐█{R}{MM}░░{R}{M}█▌ {R}{G} {R}{M}░▓█{R}{MM}░{R}{M}▀{R}{MM}▄▀{R}{M}▀▀ ░{R}{MM}░{R}{M}████ {R}
{M}░{R}{MM}░{R}{MM}░{R}{M}▌{R}{MM}▒░{R}{M}▌ ▒{R}{MM}░░{R}{M}██▌{R}{G} {R}{M} ▄▄▄ ▀{R}{MM}▄▀{R}{M}▄▄ ▒{R}{MM}▓{R}{M}██{R}{MM}░░{R}{MM}▀░{R}{G} {R}{M} ░{R}{MM}▌{R}{M}▓███{R}{MM}▐{R}{M} {R}{G} {R}{M}▀██{R}{MM}░{R}{MM}░{R}{M}█ ░█{R}{MM}▓▒{R}{MM}▐{R}{M}█▌{R}{G} {R}{M}░{R}{MM}░{R}{MM}░{R}{M}▌{R}{MM}▒░{R}{M}▌ ▒{R}{MM}░░{R}{M}██▌{R}
{M}▐█{R}{MM}▀{R}{MM}▀{R}{M}▄▀ ▓{R}{MM}░░{R}{M}██{R}{G} {R}{M}▄{R}{MM}▓▒░{R}{MM}░{R}{M}█{R}{MM}░{R}{M}▄ ▄▒{R}{MM}░{R}{M}████{R}{MM}▄{R}{M}▀{R}{G} {R}{M} {R}{MM}▌{R}{M}████{R}{MM}▐{R}{M} {R}{G} {R}{M}▒██{R}{MM}░{R}{MM}░{R}{M}█ ▒{R}{MM}▒▒▒{R}{M}██▌{R}{G} {R}{M}▐█{R}{MM}▀{R}{MM}▀{R}{M}▄▀ ▓{R}{MM}░░{R}{M}██{R}
{MM}▀{R}{M}████{R}{MM}▀▓{R}{M} ▄███▓{R}{G} {R}{M} ▀▀{R}{MM}▄██{R}{M}█{R}{MM}░{R}{M}█{R}{MM}▀{R}{M}▄{R}{MM}▀{R}{M}████{R}{MM}▄{R}{M}▀▀ {R}{G} {R}{M} ▄{R}{MM}▀▒{R}{M}█████{R}{MM}▀{R}{M}▄ {R}{G} {R}{M}■▀▒▓██ ▀{R}{MM}▄{R}{MM}░▀{R}{M}██{R}{MM}▄{R}{M} {R}{G} {R}{MM}▀{R}{M}████{R}{MM}▀▓{R}{M} ▄███▓{R}
"""
.replace("{M}", ANSI_M)
.replace("{BM}", ANSI_BM)
.replace("{G}", ANSI_G)
.replace("{MM}", ANSI_M + ANSI_BGM)
.replace("{BMM}", ANSI_BM + ANSI_BGM)
.replace("{R}", ANSI_RESET);

private static final String[] ASTRA_LOGO = ASTRA_LOGO_TEMPLATE.split("\n");

private static final int STARTUP_BLOCK_GAP = 4;

Expand All @@ -25,94 +42,117 @@ public class ConsoleUI {
private Thread idleThread;
private volatile boolean idleRunning;

private static final String[] BIG_BUNNY_ASCII = {
" , ,",
" /| |\\",
" / | | \\",
" | | | | Neeeah, ready to explore some code?",
" \\ | | /",
" \\|w|/ /",
" /_ _\\ / ,",
" /\\ _:()_():_ /]",
" ||_ : ._=Y=_ : / /",
" [)(_\\, ',__\\W/ _,' / \\",
" [) \\_/\\ _/'='\\ /-/\\)",
" [_| \\ \\ /// \\ '._ / /",
" :; \\ \\/// / | '` /",
" ;:: \\ `|: : |',_.'",
" \"\"\" \\_|: : |",
" |: : |'\".",
" /`._.' \\/",
" / /| /",
" | \\ / /",
" '. '. /",
" '. '",
" / \\ \\",
" / / \\'=,",
" .----' / \\ (\\__",
" (((____/ \\ \\ )",
" '.\\_)"
};

public void printBanner() {
clearScreen();

BunnyAnimator startupAnimator = new BunnyAnimator();
startupAnimator.setState(BunnyState.WELCOME);
// Disable line wrap for ASCII art to gracefully clip on narrow screens rather
// than break
System.out.print("\u001b[?7l");

try {
// 1. ASTra Logo Block
int logoMaxWidth = 0;
for (String line : ASTRA_LOGO) {
String clean = line.replaceAll("\u001b\\[[;\\d]*[mK]", "");
if (clean.length() > logoMaxWidth) {
logoMaxWidth = clean.length();
}
}
int logoPad = Math.max(0, (TerminalUtils.getTerminalWidth() - logoMaxWidth) / 2);
String logoOffset = " ".repeat(logoPad);

int startupHeight = getStartupBlockHeight();
for (int i = 0; i < startupHeight; i++) {
System.out.println();
}
for (String logoLine : ASTRA_LOGO) {
System.out.println(logoOffset + logoLine);
}

long start = System.currentTimeMillis();
boolean firstFrame = true;
System.out.println();
System.out.println(TerminalUtils.center(ColorPalette.ACCENT + "Code Intelligence CLI" + ColorPalette.RESET,
TerminalUtils.getTerminalWidth()));
System.out.println(
TerminalUtils.center(ColorPalette.MUTED + "Understand • Search • Analyze" + ColorPalette.RESET,
TerminalUtils.getTerminalWidth()));
System.out.println();
System.out.println();

while (System.currentTimeMillis() - start < 800) {
if (!firstFrame) {
System.out.print("\033[" + startupHeight + "A");
// 2. Bunny Mascot Block
int bunnyMaxWidth = 0;
for (String line : BIG_BUNNY_ASCII) {
if (line.length() > bunnyMaxWidth) {
bunnyMaxWidth = line.length();
}
}
firstFrame = false;

renderStartupBlock(startupAnimator.getCurrentFrame());
int bunnyPad = Math.max(0, (TerminalUtils.getTerminalWidth() - bunnyMaxWidth) / 2);
String bunnyOffset = " ".repeat(bunnyPad);

try {
Thread.sleep(120);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
for (String bunnyLine : BIG_BUNNY_ASCII) {
System.out.println(bunnyOffset + ColorPalette.MUTED + bunnyLine + ColorPalette.RESET);
}
} finally {
// Re-enable line wrap for normal text blocks and interactive prompts
System.out.print("\u001b[?7h");
}

System.out.println();
System.out.println(TerminalUtils.center(ColorPalette.ACCENT + "Welcome to ASTra" + ColorPalette.RESET,
TerminalUtils.getTerminalWidth()));
System.out.println();
System.out.println(TerminalUtils.center(ColorPalette.MUTED + "Try:" + ColorPalette.RESET,
TerminalUtils.getTerminalWidth()));
System.out.println(TerminalUtils.center(ColorPalette.TEXT + " help" + ColorPalette.RESET,
TerminalUtils.getTerminalWidth()));
System.out.println();

startIdleAnimation(startupHeight + 6);
}

public void startIdleAnimation(int linesUp) {
if (idleRunning) {
return;
// 3. Help Box
String[] box = {
"┌───────────────────────────────┐",
"│ Type 'help' to see commands │",
"└───────────────────────────────┘"
};
for (String boxLine : box) {
System.out.println(TerminalUtils.center(ColorPalette.ACCENT + boxLine + ColorPalette.RESET,
TerminalUtils.getTerminalWidth()));
}

idleRunning = true;
BunnyAnimator idleAnimator = new BunnyAnimator();
idleAnimator.setState(BunnyState.IDLE);

idleThread = new Thread(() -> {
while (idleRunning) {
try {
Thread.sleep(800);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}

if (!idleRunning) {
break;
}
System.out.println();
System.out.println();

synchronized (renderLock) {
System.out.print("\033[s\033[" + linesUp + "A");
renderStartupBlock(idleAnimator.getCurrentFrame());
System.out.print("\033[u");
System.out.flush();
}
}
});
// 4. GitHub Link
System.out.println(TerminalUtils.center(ColorPalette.TEXT + "[ GitHub ]" + ColorPalette.RESET,
TerminalUtils.getTerminalWidth()));
System.out.println();
System.out.println(TerminalUtils.renderSeparator(""));
System.out.println();
}

idleThread.setDaemon(true);
idleThread.start();
public void startIdleAnimation(int linesUp) {
// Idle animation disabled to preserve the new static layout
}

public void stopIdleAnimation() {
idleRunning = false;
if (idleThread != null) {
idleThread.interrupt();
try {
idleThread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
// Idle animation disabled
}

public void printFarewell() {
Expand Down Expand Up @@ -271,8 +311,9 @@ private int getBunnyWidth(String[] bunnyFrame) {
private int getLogoWidth() {
int max = 0;
for (String line : ASTRA_LOGO) {
if (line.length() > max) {
max = line.length();
String clean = line.replaceAll("\u001b\\[[;\\d]*[mK]", "");
if (clean.length() > max) {
max = clean.length();
}
}
return max;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public class Ansi {
public static final String RED = "\u001B[31m";
public static final String WHITE = "\u001B[37m";
public static final String GRAY = "\u001B[90m";
public static final String MAGENTA = "\u001B[35m";
public static final String BRIGHT_MAGENTA = "\u001B[95m";
}
Loading