bada-terminal / code-intel.html
VanyaJ's picture
Release BADA Terminal v2.1.0 (Enterprise Ontology, NVIDIA auto-ontology, Release Preflight)
d739b1b verified
Raw History Blame Contribute Delete
29.3 kB
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>๐Ÿงฌ BADA Code Intelligence</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--bg-base: #1e1e2e;
--bg-mantle: #181825;
--bg-crust: #11111b;
--bg-surface0: #313244;
--bg-surface1: #45475a;
--bg-surface2: #585b70;
--text: #cdd6f4;
--text-sub: #a6adc8;
--text-dim: #6c7086;
--purple: #cba6f7;
--green: #a6e3a1;
--blue: #89b4fa;
--yellow: #f9e2af;
--pink: #f5c2e7;
--red: #f38ba8;
--peach: #fab387;
--teal: #94e2d5;
--lavender: #b4befe;
--shadow: rgba(0, 0, 0, 0.3);
}
body {
font-family: 'Inter', -apple-system, sans-serif;
background: var(--bg-base);
color: var(--text);
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* Header & Tabs */
.header {
background: var(--bg-mantle);
border-bottom: 1px solid var(--bg-surface0);
padding: 14px 20px;
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
}
.title-area {
display: flex;
align-items: center;
gap: 10px;
}
.title-logo {
font-size: 20px;
background: linear-gradient(135deg, var(--blue), var(--purple));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 700;
}
.tabs {
display: flex;
background: var(--bg-crust);
padding: 4px;
border-radius: 8px;
gap: 4px;
}
.tab-btn {
padding: 8px 16px;
border-radius: 6px;
font-size: 13px;
font-weight: 500;
color: var(--text-sub);
background: transparent;
border: none;
cursor: pointer;
transition: all 0.2s ease;
}
.tab-btn:hover {
color: var(--text);
background: rgba(255, 255, 255, 0.05);
}
.tab-btn.active {
color: var(--bg-base);
background: linear-gradient(135deg, var(--blue), var(--purple));
font-weight: 600;
box-shadow: 0 4px 12px rgba(137, 180, 250, 0.2);
}
/* Main Container */
.container {
flex: 1;
display: flex;
position: relative;
overflow: hidden;
}
.tab-content {
flex: 1;
display: none;
flex-direction: column;
padding: 24px;
overflow-y: auto;
height: 100%;
}
.tab-content.active {
display: flex;
}
/* Common Card Styling */
.card {
background: var(--bg-mantle);
border: 1px solid var(--bg-surface0);
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 6px 18px var(--shadow);
}
.card-title {
font-size: 16px;
font-weight: 600;
color: var(--lavender);
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 8px;
}
/* Wizard view forms */
.form-group {
margin-bottom: 16px;
}
label {
display: block;
font-size: 13px;
font-weight: 500;
color: var(--text-sub);
margin-bottom: 6px;
}
input, select, textarea {
width: 100%;
padding: 10px 14px;
background: var(--bg-surface0);
border: 1px solid var(--bg-surface1);
border-radius: 8px;
color: var(--text);
font-size: 13px;
outline: none;
transition: all 0.2s ease;
}
input:focus, select:focus, textarea:focus {
border-color: var(--blue);
box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.15);
}
.input-row {
display: flex;
gap: 10px;
}
.btn {
padding: 10px 18px;
border-radius: 8px;
font-size: 13px;
font-weight: 600;
cursor: pointer;
border: none;
transition: all 0.2s ease;
white-space: nowrap;
display: inline-flex;
align-items: center;
gap: 8px;
}
.btn-primary {
background: linear-gradient(135deg, var(--blue), var(--purple));
color: var(--bg-crust);
}
.btn-primary:hover {
opacity: 0.9;
transform: translateY(-1px);
}
.btn-secondary {
background: var(--bg-surface1);
color: var(--text);
border: 1px solid var(--bg-surface2);
}
.btn-secondary:hover {
background: var(--bg-surface2);
}
/* List Table */
.project-table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
.project-table th, .project-table td {
padding: 12px 16px;
text-align: left;
border-bottom: 1px solid var(--bg-surface0);
}
.project-table th {
font-weight: 600;
color: var(--text-dim);
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.8px;
}
.project-table td {
font-size: 13px;
}
.badge {
padding: 3px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
}
.badge-blue { background: rgba(137, 180, 250, 0.15); color: var(--blue); }
.badge-green { background: rgba(166, 227, 161, 0.15); color: var(--green); }
.badge-yellow { background: rgba(249, 226, 175, 0.15); color: var(--yellow); }
/* Explorer View layout */
.explorer-layout {
display: grid;
grid-template-columns: 320px 1fr;
gap: 20px;
flex: 1;
height: 100%;
overflow: hidden;
}
.sidebar-panel {
display: flex;
flex-direction: column;
border-right: 1px solid var(--bg-surface0);
padding-right: 15px;
overflow-y: auto;
height: 100%;
}
.content-panel {
display: flex;
flex-direction: column;
overflow-y: auto;
height: 100%;
}
/* Symbol Tree */
.symbol-list {
list-style: none;
font-size: 13px;
}
.symbol-item {
padding: 6px 10px;
border-radius: 6px;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
transition: all 0.15s ease;
color: var(--text-sub);
}
.symbol-item:hover {
background: var(--bg-surface0);
color: var(--text);
}
.symbol-item.active {
background: rgba(137, 180, 250, 0.15);
color: var(--blue);
font-weight: 500;
}
.symbol-type-icon {
font-size: 11px;
font-weight: bold;
width: 18px;
height: 18px;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
}
.icon-file { background: rgba(137, 180, 250, 0.2); color: var(--blue); }
.icon-class { background: rgba(203, 166, 247, 0.2); color: var(--purple); }
.icon-function { background: rgba(166, 227, 161, 0.2); color: var(--green); }
/* Code detail view */
.code-viewer {
font-family: 'JetBrains Mono', monospace;
font-size: 13px;
background: var(--bg-crust);
padding: 16px;
border-radius: 8px;
border: 1px solid var(--bg-surface0);
overflow-x: auto;
line-height: 1.5;
}
/* Compare Diff View */
.compare-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 15px;
margin-bottom: 20px;
}
.diff-list {
display: flex;
flex-direction: column;
gap: 8px;
}
.diff-card {
background: var(--bg-mantle);
border: 1px solid var(--bg-surface0);
border-radius: 8px;
padding: 12px;
border-left: 4px solid var(--text-dim);
}
.diff-card.added { border-left-color: var(--green); }
.diff-card.removed { border-left-color: var(--red); }
.diff-card.modified { border-left-color: var(--yellow); }
.diff-header {
display: flex;
justify-content: space-between;
margin-bottom: 6px;
font-size: 12px;
font-weight: 600;
}
.diff-path {
font-family: 'JetBrains Mono', monospace;
color: var(--text-sub);
}
/* Loading Overlay */
.loading-overlay {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(24, 24, 37, 0.85);
z-index: 200;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 15px;
opacity: 0;
pointer-events: none;
transition: opacity 0.25s ease;
backdrop-filter: blur(4px);
}
.loading-overlay.visible {
opacity: 1;
pointer-events: auto;
}
.spinner {
width: 40px;
height: 40px;
border: 4px solid rgba(137, 180, 250, 0.2);
border-top-color: var(--blue);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.progress-container {
width: 300px;
height: 8px;
background: var(--bg-surface0);
border-radius: 4px;
overflow: hidden;
margin-top: 10px;
}
.progress-bar {
width: 0%;
height: 100%;
background: linear-gradient(90deg, var(--blue), var(--purple));
transition: width 0.3s ease;
}
</style>
<script src="src/utils/focus-restorer.js"></script>
</head>
<body>
<!-- Header -->
<div class="header">
<div class="title-area">
<div class="title-logo">๐Ÿงฌ BADA Code Intelligence</div>
</div>
<div class="tabs">
<button class="tab-btn active" onclick="switchTab('wizard')">โš™๏ธ ํ”„๋กœ์ ํŠธ ๋“ฑ๋ก/๊ด€๋ฆฌ</button>
<button class="tab-btn" onclick="switchTab('explorer')">๐Ÿ” ๊ตฌ์กฐ ํƒ์ƒ‰๊ธฐ</button>
<button class="tab-btn" onclick="switchTab('compare')">๐Ÿ“Š ํ”„๋กœ์ ํŠธ ๋น„๊ต</button>
</div>
</div>
<!-- Container -->
<div class="container">
<!-- Tab 1: Wizard (Project Management) -->
<div id="tab-wizard" class="tab-content active">
<div class="card">
<div class="card-title">โž• ์‹ ๊ทœ ์ฝ”๋“œ๋ฒ ์ด์Šค ํ”„๋กœ์ ํŠธ ๋“ฑ๋ก</div>
<div class="form-group">
<label>ํ”„๋กœ์ ํŠธ ์ด๋ฆ„</label>
<input type="text" id="projName" placeholder="์˜ˆ: langfuse-cli-agent" />
</div>
<div class="form-group">
<label>์†Œ์Šค์ฝ”๋“œ ์ ˆ๋Œ€ ๊ฒฝ๋กœ</label>
<div class="input-row">
<input type="text" id="projPath" placeholder="/Users/jungkibong/Projects/my-app" />
<button class="btn btn-secondary" onclick="selectFolder()">๐Ÿ“ ์„ ํƒ</button>
</div>
</div>
<button class="btn btn-primary" onclick="registerProject()">โš™๏ธ ํ”„๋กœ์ ํŠธ ๋“ฑ๋ก ๋ฐ ๋ถ„์„ ์‹œ์ž‘</button>
</div>
<div class="card">
<div class="card-title" style="display: flex; justify-content: space-between; align-items: center;">
<span>๐Ÿ“‹ ๋“ฑ๋ก๋œ ํ”„๋กœ์ ํŠธ ๋ชฉ๋ก</span>
<button class="btn btn-secondary" style="padding: 4px 10px; font-size: 12px;" onclick="importProject()">๐Ÿ“‚ ํŒŒ์ผ์—์„œ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ</button>
</div>
<table class="project-table">
<thead>
<tr>
<th>ํ”„๋กœ์ ํŠธ๋ช…</th>
<th>๊ฒฝ๋กœ</th>
<th>์ƒํƒœ</th>
<th>๋งˆ์ง€๋ง‰ ๋ถ„์„</th>
<th>์ž‘์—…</th>
</tr>
</thead>
<tbody id="projectListBody">
<!-- Dynamic project list -->
</tbody>
</table>
</div>
</div>
<!-- Tab 2: Explorer (Structure Analyzer) -->
<div id="tab-explorer" class="tab-content">
<div class="explorer-layout">
<div class="sidebar-panel">
<div class="form-group">
<label>๋Œ€์ƒ ํ”„๋กœ์ ํŠธ ์„ ํƒ</label>
<select id="explorerProjectSelect" onchange="loadExplorerSymbols()">
<!-- Dynamic options -->
</select>
</div>
<div style="border-top: 1px solid var(--bg-surface0); margin: 10px 0;"></div>
<h4 style="margin-bottom: 8px; font-size: 12px; color: var(--text-dim); text-transform: uppercase;">์ฝ”๋“œ ์‹ฌ๋ณผ ํŠธ๋ฆฌ</h4>
<div id="symbolTree" style="flex: 1; overflow-y: auto;">
<!-- Tree elements -->
</div>
</div>
<div class="content-panel">
<div class="card" style="flex: 1; display: flex; flex-direction: column;">
<div class="card-title">๐Ÿ” ์‹ฌ๋ณผ ์ƒ์„ธ ์ •๋ณด</div>
<div id="symbolDetailContent" style="flex: 1; display: flex; flex-direction: column; gap: 14px;">
<p style="color: var(--text-dim);">์™ผ์ชฝ ํŠธ๋ฆฌ์—์„œ ์†Œ์Šค์ฝ”๋“œ ํŒŒ์ผ์ด๋‚˜ ํด๋ž˜์Šค, ํ•จ์ˆ˜ ์‹ฌ๋ณผ์„ ์„ ํƒํ•˜์‹ญ์‹œ์˜ค.</p>
</div>
</div>
</div>
</div>
</div>
<!-- Tab 3: Compare (Diffing Tool) -->
<div id="tab-compare" class="tab-content">
<div class="card">
<div class="card-title">๐Ÿ“Š ๋‹ค์ค‘ ํ”„๋กœ์ ํŠธ ๋น„๊ต ๋ถ„์„</div>
<div class="compare-grid">
<div class="form-group">
<label>๊ธฐ์ค€ ํ”„๋กœ์ ํŠธ (Source Project)</label>
<select id="compareSourceSelect">
<!-- Dynamic options -->
</select>
</div>
<div class="form-group">
<label>๋Œ€์ƒ ํ”„๋กœ์ ํŠธ (Target Project)</label>
<select id="compareTargetSelect">
<!-- Dynamic options -->
</select>
</div>
</div>
<button class="btn btn-primary" onclick="compareProjects()">๐Ÿ“Š ๊ตฌ์กฐ ์ฐจ์ด์  ๋น„๊ต ๋ถ„์„ ์‹คํ–‰</button>
</div>
<div class="card" id="compareResultCard" style="display: none;">
<div class="card-title" id="compareResultTitle">๐Ÿ” ๋น„๊ต ๊ฒฐ๊ณผ</div>
<div class="diff-list" id="diffList">
<!-- Dynamic diff elements -->
</div>
</div>
</div>
<!-- Loading Overlay -->
<div id="loadingOverlay" class="loading-overlay">
<div class="spinner"></div>
<div class="loading-text" id="loadingText" style="font-size: 14px; font-weight: 600; color: var(--blue);">ํ”„๋กœ์ ํŠธ ์†Œ์Šค์ฝ”๋“œ ์ •์  ๋ถ„์„ ์ง„ํ–‰ ์ค‘...</div>
<div class="progress-container">
<div class="progress-bar" id="progressBar"></div>
</div>
</div>
</div>
<script>
const { ipcRenderer } = require('electron');
let allProjects = [];
window.onload = async () => {
// ํƒญ ํŒŒ๋ผ๋ฏธํ„ฐ ํ™•์ธ
const urlParams = new URLSearchParams(window.location.search);
const initialTab = urlParams.get('tab') || 'wizard';
switchTab(initialTab);
// ๋ฐ์ดํ„ฐ ๋กœ๋“œ
await refreshProjects();
};
function switchTab(tabId) {
document.querySelectorAll('.tab-btn').forEach(btn => {
btn.classList.remove('active');
if (btn.outerHTML.includes(tabId)) btn.classList.add('active');
});
document.querySelectorAll('.tab-content').forEach(content => {
content.classList.remove('active');
});
document.getElementById(`tab-${tabId}`).classList.add('active');
if (tabId === 'explorer') {
fillProjectSelects('explorerProjectSelect');
loadExplorerSymbols();
} else if (tabId === 'compare') {
fillProjectSelects('compareSourceSelect');
fillProjectSelects('compareTargetSelect');
}
}
async function refreshProjects() {
try {
allProjects = await ipcRenderer.invoke('get-code-projects') || [];
renderProjectList();
} catch (err) {
console.error('Failed to get projects:', err);
}
}
function renderProjectList() {
const tbody = document.getElementById('projectListBody');
tbody.innerHTML = '';
if (allProjects.length === 0) {
tbody.innerHTML = `<tr><td colspan="5" style="text-align: center; color: var(--text-dim);">๋“ฑ๋ก๋œ ์ฝ”๋“œ๋ฒ ์ด์Šค ํ”„๋กœ์ ํŠธ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.</td></tr>`;
return;
}
allProjects.forEach(p => {
const lastAnalyzed = p.last_analyzed_at ? new Date(p.last_analyzed_at).toLocaleString() : '๋ฏธ๋ถ„์„';
const badgeClass = p.status === 'analyzed' ? 'badge-green' : 'badge-yellow';
const badgeLabel = p.status === 'analyzed' ? '๋ถ„์„ ์™„๋ฃŒ' : '๋Œ€๊ธฐ ์ค‘';
tbody.innerHTML += `
<tr>
<td style="font-weight: 600; color: var(--lavender);">${escapeHtml(p.name)}</td>
<td style="font-family: monospace; color: var(--text-sub);">${escapeHtml(p.path)}</td>
<td><span class="badge ${badgeClass}">${badgeLabel}</span></td>
<td>${lastAnalyzed}</td>
<td style="white-space: nowrap;">
<button class="btn btn-secondary" style="padding: 4px 8px; font-size: 11px;" onclick="triggerAnalysis('${p.id}')">๐Ÿ”„ ์žฌ๋ถ„์„</button>
<button class="btn btn-secondary" style="padding: 4px 8px; font-size: 11px;" onclick="exportProject('${p.id}')">๐Ÿ’พ ๋‚ด๋ณด๋‚ด๊ธฐ</button>
<button class="btn btn-secondary" style="padding: 4px 8px; font-size: 11px; color: var(--red, #f38ba8);" onclick="deleteProject('${p.id}', '${escapeHtml(p.name)}')">๐Ÿ—‘๏ธ ์‚ญ์ œ</button>
</td>
</tr>
`;
});
}
function fillProjectSelects(selectId) {
const select = document.getElementById(selectId);
if (!select) return;
select.innerHTML = '';
if (allProjects.length === 0) {
select.innerHTML = `<option value="">๋“ฑ๋ก๋œ ํ”„๋กœ์ ํŠธ ์—†์Œ</option>`;
return;
}
allProjects.forEach(p => {
select.innerHTML += `<option value="${p.id}">${escapeHtml(p.name)}</option>`;
});
}
async function selectFolder() {
try {
const folderPath = await ipcRenderer.invoke('select-vault-folder');
if (folderPath) {
document.getElementById('projPath').value = folderPath;
}
} catch (err) {
console.error('Folder selection failed:', err);
}
}
async function registerProject() {
const name = document.getElementById('projName').value.trim();
const path = document.getElementById('projPath').value.trim();
if (!name || !path) {
alert('ํ”„๋กœ์ ํŠธ ์ด๋ฆ„๊ณผ ์ ˆ๋Œ€ ๊ฒฝ๋กœ๋ฅผ ๋ชจ๋‘ ์ž…๋ ฅํ•ด์ฃผ์‹ญ์‹œ์˜ค.');
return;
}
showLoading(true, '์ƒˆ๋กœ์šด ํ”„๋กœ์ ํŠธ ๋“ฑ๋ก ๋ฐ ์†Œ์Šค์ฝ”๋“œ ๋ถ„์„์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค...');
try {
const regResult = await ipcRenderer.invoke('register-code-project', { name, path });
if (regResult.success) {
// ๋“ฑ๋ก ์„ฑ๊ณต ํ›„ ์ •์  ๋ถ„์„ ํŠธ๋ฆฌ๊ฑฐ
await ipcRenderer.invoke('analyze-code-project', regResult.projectId);
await refreshProjects();
alert('ํ”„๋กœ์ ํŠธ ๋“ฑ๋ก ๋ฐ ์†Œ์Šค์ฝ”๋“œ AST ๋ถ„์„์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!');
} else {
alert('๋“ฑ๋ก ์‹คํŒจ: ' + regResult.error);
}
} catch (err) {
alert('์˜ค๋ฅ˜ ๋ฐœ์ƒ: ' + err.message);
} finally {
showLoading(false);
}
}
async function triggerAnalysis(projectId) {
showLoading(true, 'ํ”„๋กœ์ ํŠธ ์†Œ์Šค์ฝ”๋“œ ๋ฆฌ์ƒ˜ํ”Œ๋ง ๋ฐ AST ๋ถ„์„์„ ์ง„ํ–‰ ์ค‘์ž…๋‹ˆ๋‹ค...');
try {
const result = await ipcRenderer.invoke('analyze-code-project', projectId);
if (result.success) {
await refreshProjects();
alert('๋ถ„์„ ์™„๋ฃŒ!');
} else {
alert('๋ถ„์„ ์‹คํŒจ: ' + result.error);
}
} catch (err) {
alert('๋ถ„์„ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: ' + err.message);
} finally {
showLoading(false);
}
}
// ๋“ฑ๋ก๋œ ํ”„๋กœ์ ํŠธ ์‚ญ์ œ โ€” ๋“ฑ๋ก ์ •๋ณด์™€ ์ธ๋ฑ์‹ฑ๋œ ์ฝ”๋“œ ๋ฐ์ดํ„ฐ๋ฅผ ํ•จ๊ป˜ ์ œ๊ฑฐ
async function deleteProject(projectId, name) {
if (!confirm(`'${name}' ํ”„๋กœ์ ํŠธ๋ฅผ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?\n๋“ฑ๋ก ์ •๋ณด์™€ ์ธ๋ฑ์‹ฑ๋œ ์ฝ”๋“œ ์‹ฌ๋ณผ/๊ด€๊ณ„/์ด๋ ฅ์ด ๋ชจ๋‘ ์ œ๊ฑฐ๋ฉ๋‹ˆ๋‹ค.`)) return;
showLoading(true, 'ํ”„๋กœ์ ํŠธ ์‚ญ์ œ ์ค‘...');
try {
const result = await ipcRenderer.invoke('delete-code-project', projectId);
if (result.success) {
await refreshProjects();
alert('์‚ญ์ œ ์™„๋ฃŒ!');
} else {
alert('์‚ญ์ œ ์‹คํŒจ: ' + result.error);
}
} catch (err) {
alert('์‚ญ์ œ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: ' + err.message);
} finally {
showLoading(false);
}
}
// ํ”„๋กœ์ ํŠธ ์ฝ”๋“œ ์ธํ…”๋ฆฌ์ „์Šค ๋ฐ์ดํ„ฐ๋ฅผ JSON ํŒŒ์ผ๋กœ ๋‚ด๋ณด๋‚ด๊ธฐ
async function exportProject(projectId) {
showLoading(true, '๋‚ด๋ณด๋‚ด๊ธฐ ํŒŒ์ผ ์ƒ์„ฑ ์ค‘...');
try {
const result = await ipcRenderer.invoke('export-code-project', projectId);
if (result.success) {
alert(`๋‚ด๋ณด๋‚ด๊ธฐ ์™„๋ฃŒ!\n๊ฒฝ๋กœ: ${result.filePath}\n์‹ฌ๋ณผ ${result.symbolCount}๊ฐœ`);
} else if (!result.canceled) {
alert('๋‚ด๋ณด๋‚ด๊ธฐ ์‹คํŒจ: ' + result.error);
}
} catch (err) {
alert('๋‚ด๋ณด๋‚ด๊ธฐ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: ' + err.message);
} finally {
showLoading(false);
}
}
// JSON ํŒŒ์ผ์—์„œ ํ”„๋กœ์ ํŠธ ์ฝ”๋“œ ์ธํ…”๋ฆฌ์ „์Šค ๋ฐ์ดํ„ฐ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
async function importProject() {
showLoading(true, '๋ถˆ๋Ÿฌ์˜ค๊ธฐ ํŒŒ์ผ ์ฒ˜๋ฆฌ ์ค‘...');
try {
const result = await ipcRenderer.invoke('import-code-project');
if (result.success) {
await refreshProjects();
alert(`๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์™„๋ฃŒ!\nํ”„๋กœ์ ํŠธ: ${result.name}\n์‹ฌ๋ณผ ${result.symbolCount}๊ฐœ`);
} else if (!result.canceled) {
alert('๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์‹คํŒจ: ' + result.error);
}
} catch (err) {
alert('๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: ' + err.message);
} finally {
showLoading(false);
}
}
async function loadExplorerSymbols() {
const projectId = document.getElementById('explorerProjectSelect').value;
const tree = document.getElementById('symbolTree');
tree.innerHTML = '';
if (!projectId) {
tree.innerHTML = `<p style="color: var(--text-dim); font-size: 13px;">์„ ํƒ๋œ ํ”„๋กœ์ ํŠธ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.</p>`;
return;
}
try {
const symbols = await ipcRenderer.invoke('get-code-symbols', projectId, { limit: 100 });
if (symbols.length === 0) {
tree.innerHTML = `<p style="color: var(--text-dim); font-size: 13px;">์ฝ”๋“œ ๊ตฌ์กฐ ๋ถ„์„ ๊ฒฐ๊ณผ๊ฐ€ ๋น„์–ด์žˆ์Šต๋‹ˆ๋‹ค. ์žฌ๋ถ„์„์„ ์‹คํ–‰ํ•ด๋ณด์‹ญ์‹œ์˜ค.</p>`;
return;
}
symbols.forEach(sym => {
const st = sym.symbol_type || sym.type; // DB๋Š” symbol_type ๋ฐ˜ํ™˜ (๊ตฌ๋ฒ„์ „ ํ˜ธํ™˜ ์œ„ํ•ด type ํด๋ฐฑ)
const typeLabel = st === 'file' ? 'F' : (st === 'class' ? 'C' : 'M');
const typeIconClass = st === 'file' ? 'icon-file' : (st === 'class' ? 'icon-class' : 'icon-function');
const li = document.createElement('div');
li.className = 'symbol-item';
li.onclick = () => showSymbolDetail(sym);
li.innerHTML = `
<span class="symbol-type-icon ${typeIconClass}">${typeLabel}</span>
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${escapeHtml(sym.name)}</span>
`;
tree.appendChild(li);
});
} catch (err) {
tree.innerHTML = `<p style="color: var(--red); font-size: 13px;">์‹ฌ๋ณผ ๋กœ๋“œ ์‹คํŒจ: ${err.message}</p>`;
}
}
function showSymbolDetail(symbol) {
document.querySelectorAll('.symbol-item').forEach(el => el.classList.remove('active'));
event.currentTarget.classList.add('active');
const detail = document.getElementById('symbolDetailContent');
detail.innerHTML = `
<div>
<h3 style="font-size: 15px; color: var(--lavender); margin-bottom: 6px;">${escapeHtml(symbol.name)}</h3>
<p style="font-size: 12px; color: var(--text-sub);">ํƒ€์ž…: <strong style="color: var(--blue);">${(symbol.symbol_type || symbol.type || 'N/A').toUpperCase()}</strong></p>
<p style="font-size: 12px; color: var(--text-sub);">์ •์˜ ํŒŒ์ผ: <span style="font-family: monospace;">${escapeHtml(symbol.file_path || 'N/A')}</span></p>
${symbol.start_line ? `<p style="font-size: 12px; color: var(--text-sub);">์ฝ”๋“œ ๋ผ์ธ: L${symbol.start_line} ~ L${symbol.end_line}</p>` : ''}
</div>
<div style="border-top: 1px solid var(--bg-surface0); margin: 10px 0;"></div>
<div style="flex: 1; display: flex; flex-direction: column; gap: 8px;">
<h4 style="font-size: 13px; color: var(--text-sub);">์‹ฌ๋ณผ ๊ฐœ์š” ๋ฐ ๊ตฌ์กฐ ์ •๋ณด</h4>
<div class="code-viewer" style="flex: 1; max-height: 400px; overflow-y: auto;">
${escapeHtml(JSON.stringify(symbol, null, 2))}
</div>
</div>
`;
}
async function compareProjects() {
const srcId = document.getElementById('compareSourceSelect').value;
const tgtId = document.getElementById('compareTargetSelect').value;
if (!srcId || !tgtId) {
alert('๋น„๊ตํ•  ๋‘ ํ”„๋กœ์ ํŠธ๋ฅผ ์„ ํƒํ•ด์ฃผ์‹ญ์‹œ์˜ค.');
return;
}
showLoading(true, '๋‘ ํ”„๋กœ์ ํŠธ์˜ ์ •์  ๊ตฌ์กฐ AST ์ฐจ์ด์ ์„ ๋ถ„์„ ์ค‘์ž…๋‹ˆ๋‹ค...');
try {
const result = await ipcRenderer.invoke('compare-code-projects', srcId, tgtId, {});
const resultCard = document.getElementById('compareResultCard');
const diffList = document.getElementById('diffList');
diffList.innerHTML = '';
resultCard.style.display = 'block';
if (!result.added && !result.removed && !result.modified) {
diffList.innerHTML = `<p style="color: var(--text-dim); text-align: center; padding: 20px 0;">๋‘ ํ”„๋กœ์ ํŠธ ๊ฐ„์˜ ์‹ฌ๋ณผ ๋ฐ ์•„ํ‚คํ…์ฒ˜ ์ฐจ์ด์ ์ด ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.</p>`;
return;
}
const added = result.added || [];
const removed = result.removed || [];
const modified = result.modified || [];
added.forEach(item => {
diffList.innerHTML += `
<div class="diff-card added">
<div class="diff-header" style="color: var(--green);">
<span>[+] ์‹ ๊ทœ ์ถ”๊ฐ€๋จ</span>
<span>Type: ${item.type.toUpperCase()}</span>
</div>
<div class="diff-path">${escapeHtml(item.name)}</div>
<div style="font-size: 12px; color: var(--text-dim); margin-top: 4px;">ํŒŒ์ผ: ${escapeHtml(item.file_path)}</div>
</div>
`;
});
removed.forEach(item => {
diffList.innerHTML += `
<div class="diff-card removed">
<div class="diff-header" style="color: var(--red);">
<span>[-] ์‚ญ์ œ๋จ</span>
<span>Type: ${item.type.toUpperCase()}</span>
</div>
<div class="diff-path">${escapeHtml(item.name)}</div>
<div style="font-size: 12px; color: var(--text-dim); margin-top: 4px;">ํŒŒ์ผ: ${escapeHtml(item.file_path)}</div>
</div>
`;
});
modified.forEach(item => {
diffList.innerHTML += `
<div class="diff-card modified">
<div class="diff-header" style="color: var(--yellow);">
<span>[*] ๊ตฌ์กฐ ๋ณ€๊ฒฝ ๊ฐ์ง€</span>
<span>Type: ${item.type.toUpperCase()}</span>
</div>
<div class="diff-path">${escapeHtml(item.name)}</div>
<div style="font-size: 12px; color: var(--text-dim); margin-top: 4px;">ํŒŒ์ผ: ${escapeHtml(item.file_path)}</div>
</div>
`;
});
if (added.length === 0 && removed.length === 0 && modified.length === 0) {
diffList.innerHTML = `<p style="color: var(--text-dim); text-align: center; padding: 20px 0;">๊ตฌ์กฐ์  ๋ณ€๊ฒฝ์ด ๋ฐœ๊ฒฌ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.</p>`;
}
} catch (err) {
alert('๋น„๊ต ๋ถ„์„ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: ' + err.message);
} finally {
showLoading(false);
}
}
function showLoading(show, text = '์ •์  ๋ถ„์„ ์ง„ํ–‰ ์ค‘...') {
const overlay = document.getElementById('loadingOverlay');
const textEl = document.getElementById('loadingText');
const bar = document.getElementById('progressBar');
textEl.textContent = text;
if (show) {
overlay.classList.add('visible');
bar.style.width = '10%';
setTimeout(() => bar.style.width = '35%', 300);
setTimeout(() => bar.style.width = '70%', 1000);
setTimeout(() => bar.style.width = '95%', 2500);
} else {
bar.style.width = '100%';
setTimeout(() => {
overlay.classList.remove('visible');
bar.style.width = '0%';
}, 300);
}
}
function escapeHtml(str) {
if (!str) return '';
return str.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}
ipcRenderer.on('switch-tab', (event, tabId) => {
switchTab(tabId);
});
</script>
</body>
</html>