File size: 30,153 Bytes
d739b1b | 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 | <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>π BADA κ°λ° μμ
κ΄λ¦¬</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 */
.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(--pink));
-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(--pink));
font-weight: 600;
box-shadow: 0 4px 12px rgba(245, 194, 231, 0.2);
}
/* Layouts */
.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;
}
.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;
}
.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;
}
textarea {
resize: vertical;
font-family: inherit;
}
input:focus, select:focus, textarea:focus {
border-color: var(--blue);
box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.15);
}
.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(--pink));
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);
}
/* Kanban Board */
.kanban-board {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16px;
flex: 1;
overflow-x: auto;
margin-top: 10px;
}
.kanban-col {
background: var(--bg-crust);
border: 1px solid var(--bg-surface0);
border-radius: 10px;
padding: 14px;
display: flex;
flex-direction: column;
max-height: 100%;
overflow-y: auto;
}
.kanban-col-title {
font-size: 13px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.8px;
margin-bottom: 12px;
color: var(--text-dim);
display: flex;
justify-content: space-between;
align-items: center;
}
.kanban-card-list {
display: flex;
flex-direction: column;
gap: 10px;
flex: 1;
}
.kanban-card {
background: var(--bg-mantle);
border: 1px solid var(--bg-surface0);
border-radius: 8px;
padding: 12px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
cursor: grab;
transition: all 0.2s ease;
}
.kanban-card:hover {
border-color: var(--blue);
transform: translateY(-1px);
}
.kanban-card-title {
font-size: 13px;
font-weight: 600;
color: var(--lavender);
margin-bottom: 6px;
}
.kanban-card-desc {
font-size: 11px;
color: var(--text-sub);
line-height: 1.4;
margin-bottom: 8px;
}
.kanban-card-meta {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 10px;
color: var(--text-dim);
}
/* Troubleshoot KB list */
.search-row {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.troubleshoot-list {
display: flex;
flex-direction: column;
gap: 12px;
}
.troubleshoot-card {
background: var(--bg-mantle);
border: 1px solid var(--bg-surface0);
border-radius: 10px;
padding: 16px;
border-left: 4px solid var(--red);
transition: all 0.2s ease;
}
.troubleshoot-card:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(243, 139, 168, 0.1);
}
.ts-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.ts-pattern {
font-family: 'JetBrains Mono', monospace;
font-size: 14px;
font-weight: 600;
color: var(--text);
}
.ts-details {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 15px;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid var(--bg-surface0);
font-size: 12px;
}
.ts-box-title {
font-weight: 600;
color: var(--yellow);
margin-bottom: 4px;
}
/* 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(245, 194, 231, 0.2);
border-top-color: var(--pink);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>
<script src="src/utils/focus-restorer.js"></script>
</head>
<body>
<!-- Header -->
<div class="header">
<div class="title-area">
<div class="title-logo">π BADA κ°λ° μμ
κ΄λ¦¬</div>
</div>
<div class="tabs">
<button class="tab-btn active" onclick="switchTab('planning')">π‘ μꡬμ¬ν κΈ°ν</button>
<button class="tab-btn" onclick="switchTab('kanban')">π μΉΈλ° λ³΄λ</button>
<button class="tab-btn" onclick="switchTab('troubleshoot')">π νΈλ¬λΈμν
μ§μ</button>
</div>
</div>
<!-- Container -->
<div class="container">
<!-- Tab 1: Requirements & Planning -->
<div id="tab-planning" class="tab-content active">
<div class="card">
<div class="card-title">π‘ μ κ· κΈ°λ₯ κ°λ° κΈ°ν λ° μν₯λ λΆμ</div>
<div class="form-group">
<label>λμ νλ‘μ νΈ μ ν</label>
<select id="planningProjectSelect">
<!-- Dynamic options -->
</select>
</div>
<div class="form-group">
<label>κΈ°νμ μ λͺ©</label>
<input type="text" id="planTitle" placeholder="μ: OAuth2 μΈμ¦ λ‘κ·ΈμΈ κΈ°λ₯ ꡬν" />
</div>
<div class="form-group">
<label>λͺ©ν (Goal)</label>
<input type="text" id="planGoal" placeholder="μ: κ΅¬κΈ λ° λ€μ΄λ² μμ
λ‘κ·ΈμΈ μ°λ" />
</div>
<div class="form-group">
<label>κΈ°λ₯ μμΈ μꡬμ¬ν (Requirements)</label>
<textarea id="planRequirements" rows="5" placeholder="- λ‘κ·ΈμΈ νμ΄μ§ λ²νΌ λ
ΈμΆ - ν ν° κ²μ¦ λ―Έλ€μ¨μ΄ ꡬν - DB μ¬μ©μ μ μ₯ μ²λ¦¬"></textarea>
</div>
<button class="btn btn-primary" onclick="createPlan()">βοΈ κΈ°ν μμ± λ° μλΈνμ€ν¬ λΆν΄</button>
<div class="form-group"><label for="goalPlanningBudget">κ³νΒ·λ°°μ λͺ¨λΈ μμ° (USD, μ ν)</label><input id="goalPlanningBudget" type="number" min="0.000001" step="any" placeholder="λ―Έμ€μ " /></div>
<div class="form-group"><label for="goalPlanningReserve">κ³ν μμ²λΉ μμ½ (USD, μ ν)</label><input id="goalPlanningReserve" type="number" min="0.000001" step="any" placeholder="μλ΅νλ©΄ λ¨μ κ³ν μμ° μμ½" /></div>
<div class="form-group"><label for="goalExecutionBudget">μν¬νλ‘μ° μ€ν μμ° (USD, μ ν)</label><input id="goalExecutionBudget" type="number" min="0.000001" step="any" placeholder="κ³ν μμ°κ³Ό λ³λ" /></div>
<div class="form-group"><label for="goalExecutionReserve">μ€ν μμ²λΉ μμ½ (USD, μ ν)</label><input id="goalExecutionReserve" type="number" min="0.000001" step="any" placeholder="λ―Έμ€μ μ΄λ©΄ κΈ°μ‘΄ λμ μ μ§" /></div>
<small>μμ½μ μ€μ μ²κ΅¬ μνμ΄ μλλλ€. λΉμ© λ―ΈμΒ·μμ½ μ΄κ³Όλ κ²ν λ‘ λ©μΆλ©°, μμ ν μ¬κ³νλ κ°μ κ³ν μμ°μ μ¬μ©ν©λλ€.</small>
<!-- μμ¨ μμ΄μ νΈ: κ° κ³νμ κ²ν ν λ€ κΈ°μ‘΄ μν¬νλ‘μ°λ₯Ό μ€ννλ€. -->
<button id="autonomousStart" class="btn btn-primary" style="background:#6d28d9;" onclick="runAutonomousGoal()">π μμ¨ μ€ν (κ³νβμν¬νλ‘μ°βμ€ν)</button>
<button id="autonomousCancel" class="btn" onclick="cancelAutonomousGoal()" disabled>λͺ©ν μμ
μ·¨μ</button>
<button id="planningCostReview" class="btn" onclick="openGoalPlanningReconciliation(document.getElementById('planningProjectSelect').value, (...args) => ipcRenderer.invoke(...args))">κ³νΒ·λ°°μ λΉμ© κ²ν </button>
<button id="learningRecoveryReview" class="btn" onclick="openGoalLearningRecovery(document.getElementById('planningProjectSelect').value, (...args) => ipcRenderer.invoke(...args))">νμ΅ μ€λ¨ κ²ν Β·λ§λ¬΄λ¦¬</button>
<button id="planningTakeoverReview" class="btn" onclick="openGoalPlanningTakeover(document.getElementById('planningProjectSelect').value, (...args) => ipcRenderer.invoke(...args))">μ€λ¨λ κ³ν μ΄μ΄κ°κΈ°</button>
<button id="planningPricingEdit" class="btn" onclick="configureGoalPricing((...args) => ipcRenderer.invoke(...args))">μ΄ λͺ©νμ λ¨κ°Β·μΆμ² μ€μ </button>
<small id="planningPricingStatus">λ¨κ° μΆμ λ―Έμ€μ Β· κΈμ‘ λ―Έλ³΄κ³ μμ²μ κ²ν μμ λ©μΆ₯λλ€.</small>
<!-- μμ¨ μ€ν μ§ν λ‘κ·Έ -->
<div id="autonomousLog" style="display:none; margin-top:16px; padding:12px; background:#1e1e2e; color:#cdd6f4; border-radius:8px; font-family:monospace; font-size:12px; max-height:280px; overflow:auto; white-space:pre-wrap;"></div>
</div>
</div>
<!-- Tab 2: Kanban Board -->
<div id="tab-kanban" class="tab-content">
<div class="form-group" style="max-width: 300px; margin-bottom: 20px;">
<label>νλ‘μ νΈ νν°</label>
<select id="kanbanProjectSelect" onchange="loadKanbanTasks()">
<!-- Dynamic options -->
</select>
</div>
<div class="kanban-board">
<!-- Todo Column -->
<div class="kanban-col">
<div class="kanban-col-title">ν΄μΌ ν μΌ <span id="count-todo" style="color: var(--blue);">0</span></div>
<div class="kanban-card-list" id="col-todo" ondragover="allowDrop(event)" ondrop="drop(event, 'todo')">
<!-- Cards -->
</div>
</div>
<!-- In Progress Column -->
<div class="kanban-col">
<div class="kanban-col-title">μ§ν μ€ <span id="count-in_progress" style="color: var(--purple);">0</span></div>
<div class="kanban-card-list" id="col-in_progress" ondragover="allowDrop(event)" ondrop="drop(event, 'in_progress')">
<!-- Cards -->
</div>
</div>
<!-- Completed Column -->
<div class="kanban-col">
<div class="kanban-col-title">μλ£λ¨ <span id="count-completed" style="color: var(--green);">0</span></div>
<div class="kanban-card-list" id="col-completed" ondragover="allowDrop(event)" ondrop="drop(event, 'completed')">
<!-- Cards -->
</div>
</div>
<!-- Failed Column -->
<div class="kanban-col">
<div class="kanban-col-title">보λ₯/μ€ν¨ <span id="count-failed" style="color: var(--red);">0</span></div>
<div class="kanban-card-list" id="col-failed" ondragover="allowDrop(event)" ondrop="drop(event, 'failed')">
<!-- Cards -->
</div>
</div>
</div>
</div>
<!-- Tab 3: Troubleshoot KB -->
<div id="tab-troubleshoot" class="tab-content">
<div class="card">
<div class="card-title">π μλ¬ νΈλ¬λΈμν
μ§μ κ²μ</div>
<div class="form-group" style="max-width: 300px;">
<label>νλ‘μ νΈ νν°</label>
<select id="tsProjectSelect" onchange="searchTroubleshoot()">
<!-- Dynamic options -->
</select>
</div>
<div class="search-row">
<input type="text" id="tsSearchInput" placeholder="μλ¬ μ ν, νμΌλͺ
, λ‘κ·Έ ν€μλλ‘ μ§μ κ²μ..." style="flex: 1;" />
<button class="btn btn-primary" onclick="searchTroubleshoot()">π κ²μ</button>
</div>
<div class="troubleshoot-list" id="tsList">
<!-- Dynamic troubleshoot entries -->
</div>
</div>
</div>
<!-- Loading Overlay -->
<div id="loadingOverlay" class="loading-overlay">
<div class="spinner"></div>
<div class="loading-text" id="loadingText">μν₯λ λͺ¨λΈ κ³μ° λ° μλΈνμ€ν¬ λΆν΄ μ§ν μ€...</div>
</div>
</div>
<script src="goal-planning-reconciliation.js"></script>
<script src="goal-planning-takeover.js"></script>
<script src="usage-reconciliation.js"></script>
<script src="goal-learning-recovery.js"></script>
<script src="goal-planning-pricing.js"></script>
<script>
const { ipcRenderer } = require('electron');
let allProjects = [];
window.onload = async () => {
const urlParams = new URLSearchParams(window.location.search);
const initialTab = urlParams.get('tab') || 'planning';
switchTab(initialTab);
await loadProjects();
};
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 === 'kanban') {
loadKanbanTasks();
} else if (tabId === 'troubleshoot') {
searchTroubleshoot();
}
}
async function loadProjects() {
try {
allProjects = await ipcRenderer.invoke('get-code-projects') || [];
fillSelect('planningProjectSelect');
fillSelect('kanbanProjectSelect');
fillSelect('tsProjectSelect');
} catch (err) {
console.error('Failed to load projects:', err);
}
}
function fillSelect(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 createPlan() {
const projectId = document.getElementById('planningProjectSelect').value;
const title = document.getElementById('planTitle').value.trim();
const goal = document.getElementById('planGoal').value.trim();
const requirements = document.getElementById('planRequirements').value.trim();
if (!projectId) {
alert('λμ νλ‘μ νΈλ₯Ό μ νν΄μ£Όμμμ€.');
return;
}
if (!title || !goal) {
alert('κΈ°νμ μ λͺ©κ³Ό λͺ©νλ₯Ό μ
λ ₯ν΄μ£Όμμμ€.');
return;
}
showLoading(true, 'π€ μμ΄μ νΈ λΈλ μΈμ΄ μν₯λλ₯Ό νκ°νκ³ νμ κ°λ° λ¨κ³λ₯Ό λλκ³ μμ΅λλ€...');
try {
const result = await ipcRenderer.invoke('create-dev-plan', projectId, title, goal, requirements);
if (result.success) {
alert('μ±κ³΅! κΈ°νμκ° μν€ λ° λ°μ΄ν°λ² μ΄μ€μ μ μ¬λμμΌλ©°, νμ νμ€ν¬κ° μΉΈλ°μ λ±λ‘λμμ΅λλ€.');
// μμ μ΄κΈ°ν
document.getElementById('planTitle').value = '';
document.getElementById('planGoal').value = '';
document.getElementById('planRequirements').value = '';
switchTab('kanban');
} else {
alert('κΈ°ν μμ± μ€ν¨: ' + result.error);
}
} catch (err) {
alert('μ€λ₯ λ°μ: ' + err.message);
} finally {
showLoading(false);
}
}
// --- μμ¨ μ€ν (Goal β Plan β Workflow β Execute β Replan) ---
let ownedGoalId=null;
async function cancelAutonomousGoal(){
if(!ownedGoalId)return;
try{const result=await ipcRenderer.invoke('cancel-autonomous-goal',ownedGoalId);if(result.success){document.getElementById('autonomousCancel').disabled=true;appendAutonomousLog('μ·¨μ μμ²μ 보λμ΅λλ€. μμ μμ²μ μ’
λ£Β·λΉμ© μ μ₯μ νμΈν©λλ€.');}else appendAutonomousLog('νμ¬ μ°½μ΄ μμ ν μ§ν λͺ©νλ₯Ό νμΈν μ μμ΅λλ€.');}
catch{appendAutonomousLog('μ·¨μ μμ²μ μ λ¬νμ§ λͺ»νμ΅λλ€. νμ¬ μνλ₯Ό νμΈν΄μ£ΌμΈμ.');}
}
function appendAutonomousLog(line) {
const box = document.getElementById('autonomousLog');
box.style.display = 'block';
const ts = new Date().toLocaleTimeString();
box.textContent += `[${ts}] ${line}\n`;
box.scrollTop = box.scrollHeight;
}
// λ©μΈ νλ‘μΈμ€κ° 보λ΄λ μμ¨ μ€ν μ§ν μ΄λ²€νΈλ₯Ό μμ ν΄ λ‘κ·Έμ μΆλ ₯
ipcRenderer.on('autonomous-goal-event', (event, { channel, payload }) => {
if(channel==='goal:start'){ownedGoalId=payload.goalId;document.getElementById('autonomousCancel').disabled=false;}
const map = {
'goal:start': () => `π μμ¨ λͺ©ν μμ (μ¬κ³ν μ΅λ ${payload.maxReplans}ν)`,
'goal:planning': () => `π§ [μλ ${payload.attempt}] λͺ©ν λΆν΄ μ€...`,
'goal:plan': () => `π [μλ ${payload.attempt}] κ³ν μ립 μλ£ β λ
Έλ ${payload.nodeCount}κ° (workflow=${payload.workflowId})`,
'goal:waiting': () => `π [κ³ν ${payload.attempt}] κ³΅ν΅ μΉμΈ νλ©΄μμ μΉμΈΒ·λ°λ €Β·μμ μ§μλ₯Ό κΈ°λ€λ¦½λλ€. λ΄ κ΄μ μμλ νμΈν μ μμ΅λλ€.`,
'goal:running': () => `βοΈ [μλ ${payload.attempt}] μν¬νλ‘μ° μ€ν μ€ (run=${payload.runId})`,
'goal:replan': () => `π μ¬κ³ν β λ€μ μλ ${payload.nextAttempt}`,
'goal:complete': () => `β
κ³ν μ€ν μλ£ (run=${payload.runId}, μ΄ ${payload.attempts}ν μλ). λͺ©ν μΆ©μ‘±μ κ·Όκ±°λ₯Ό νμΈν΄μ£ΌμΈμ.`,
'goal:pause': () => `βΈ μΌμμ μ§ β ${payload.code || 'μλ μμ
μ κ²ν ν΄μ£ΌμΈμ.'}`,
'goal:review': () => `π κ²ν νμ β ${payload.code || 'κ°μ μ€νμ νμΈν΄μ£ΌμΈμ.'}`,
'goal:fail': () => `β μ€ν¨ β ${payload.attempts}ν μλ μμ§. μ€λ₯: ${payload.error}`,
};
const fn = map[channel];
if (fn) appendAutonomousLog(fn());
});
async function runAutonomousGoal() {
const projectId = document.getElementById('planningProjectSelect').value;
const title = document.getElementById('planTitle').value.trim();
const goalText = document.getElementById('planGoal').value.trim();
const requirements = document.getElementById('planRequirements').value.trim();
if (!projectId) { alert('νλ‘μ νΈλ₯Ό μ ννμΈμ.'); return; }
const goal = [title, goalText, requirements].filter(s => s).join('\n\n');
if (!goal) { alert('λͺ©ν(μ λͺ©/λͺ©ν/μꡬμ¬ν μ€ νλ μ΄μ)λ₯Ό μ
λ ₯νμΈμ.'); return; }
const budgets={};
for(const [field,key]of [['goalPlanningBudget','planningBudgetUsd'],['goalPlanningReserve','planningRequestReserveUsd'],['goalExecutionBudget','budgetUsd'],['goalExecutionReserve','requestReserveUsd']]){
const value=document.getElementById(field).value.trim();if(!value)continue;
const amount=Number(value);if(!Number.isFinite(amount)||amount<=0){alert('μμ°κ³Ό μμ½μλ μμλ₯Ό μ
λ ₯ν΄μ£ΌμΈμ.');return;}budgets[key]=amount;
}
if(budgets.planningRequestReserveUsd!=null&&(budgets.planningBudgetUsd==null||budgets.planningRequestReserveUsd>budgets.planningBudgetUsd)){alert('μμ² μμ½μ κ³ν μμ° μμμ μ€μ ν΄μ£ΌμΈμ.');return;}
if(budgets.requestReserveUsd!=null&&budgets.budgetUsd!=null&&budgets.requestReserveUsd>budgets.budgetUsd){alert('μ€ν μμ² μμ½μ μ€ν μμ° μμμ μ€μ ν΄μ£ΌμΈμ.');return;}
document.getElementById('autonomousLog').textContent = '';
document.getElementById('autonomousStart').disabled=true;
appendAutonomousLog('μμ² μ μ‘...');
try {
const res = await ipcRenderer.invoke('run-autonomous-goal', projectId, goal, { maxReplans: 2,...budgets,planningPricingPolicies:getGoalPricingPolicies() });
if (res && res.success) {
appendAutonomousLog(`π μλ£ (run=${res.runId})`);
} else {
appendAutonomousLog(`μ’
λ£(μ€ν¨): ${res && res.error ? res.error : 'μμΈ λ―Έμ'}`);
}
} catch (err) {
appendAutonomousLog(`μ€λ₯: ${err.message}`);
} finally {
ownedGoalId=null;document.getElementById('autonomousCancel').disabled=true;document.getElementById('autonomousStart').disabled=false;
}
}
// --- Kanban Logic ---
let draggedTaskId = null;
async function loadKanbanTasks() {
const projectId = document.getElementById('kanbanProjectSelect').value;
// Clear cols
const cols = ['todo', 'in_progress', 'completed', 'failed'];
cols.forEach(col => {
document.getElementById(`col-${col}`).innerHTML = '';
document.getElementById(`count-${col}`).textContent = '0';
});
if (!projectId) return;
try {
const plans = await ipcRenderer.invoke('get-dev-plans', projectId);
const colCounts = { todo: 0, in_progress: 0, completed: 0, failed: 0 };
plans.forEach(plan => {
const tasks = plan.tasks || [];
tasks.forEach(t => {
const status = t.status || 'todo';
const colEl = document.getElementById(`col-${status}`);
if (!colEl) return;
colCounts[status]++;
const card = document.createElement('div');
card.className = 'kanban-card';
card.draggable = true;
card.id = `task-${t.id}`;
card.ondragstart = (e) => {
draggedTaskId = t.id;
e.dataTransfer.setData('text/plain', t.id);
};
card.innerHTML = `
<div class="kanban-card-title">${escapeHtml(t.title)}</div>
<div class="kanban-card-desc">${escapeHtml(t.description || 'μμΈ λ΄μ© μμ')}</div>
<div class="kanban-card-meta">
<span>νμΌ: ${escapeHtml(t.target_file || 'N/A')}</span>
<span>${t.difficulty ? `λμ΄λ: ${t.difficulty}` : ''}</span>
</div>
`;
colEl.appendChild(card);
});
});
// Set counts
cols.forEach(col => {
document.getElementById(`count-${col}`).textContent = colCounts[col];
});
} catch (err) {
console.error('Failed to load kanban tasks:', err);
}
}
function allowDrop(e) {
e.preventDefault();
}
async function drop(e, newStatus) {
e.preventDefault();
const taskId = e.dataTransfer.getData('text/plain') || draggedTaskId;
if (!taskId) return;
try {
const updateResult = await ipcRenderer.invoke('update-dev-task', taskId, { status: newStatus });
if (updateResult.success) {
loadKanbanTasks();
} else {
alert('νμ€ν¬ μ
λ°μ΄νΈ μ€ν¨: ' + updateResult.error);
}
} catch (err) {
alert('μ
λ°μ΄νΈ μ€ μ€λ₯ λ°μ: ' + err.message);
}
}
// --- Troubleshoot KB ---
async function searchTroubleshoot() {
const projectId = document.getElementById('tsProjectSelect').value;
const query = document.getElementById('tsSearchInput').value.trim();
const listEl = document.getElementById('tsList');
listEl.innerHTML = '';
if (!projectId) {
listEl.innerHTML = `<p style="color: var(--text-dim); text-align: center; padding: 20px 0;">μ‘°ν λμ νλ‘μ νΈλ₯Ό μ νν΄μ£Όμμμ€.</p>`;
return;
}
try {
const entries = await ipcRenderer.invoke('search-troubleshoot-kb', projectId, query);
if (entries.length === 0) {
listEl.innerHTML = `<p style="color: var(--text-dim); text-align: center; padding: 20px 0;">ν¬μ°©λ νΈλ¬λΈμν
μ§μμ΄ μμ΅λλ€.</p>`;
return;
}
entries.forEach(e => {
listEl.innerHTML += `
<div class="troubleshoot-card">
<div class="ts-header">
<span class="ts-pattern">${escapeHtml(e.error_pattern)}</span>
<span class="badge badge-yellow">${e.error_type.toUpperCase()}</span>
</div>
<div style="font-size: 11px; color: var(--text-dim); margin-bottom: 8px;">λμ λ°μ: <strong style="color: var(--pink);">${e.hit_count || 1}</strong>ν | μ΅μ’
λ°μ: ${e.last_hit_at || e.created_at || 'κΈ°λ‘ μμ'}</div>
<div class="ts-details">
<div>
<div class="ts-box-title">π κ·Όλ³Έ μμΈ</div>
<div style="color: var(--text-sub); line-height: 1.4;">${escapeHtml(e.root_cause || 'λΆμ μ€')}</div>
</div>
<div>
<div class="ts-box-title">π‘ ν΄κ²°μ±
λ° ν¨μΉ</div>
<div style="color: var(--text-sub); line-height: 1.4;">${escapeHtml(e.solution)}</div>
</div>
</div>
${(e.affected_files && e.affected_files.length > 0) ? `
<div style="margin-top: 10px; font-size: 11px; color: var(--text-dim);">
μ°κ΄ νμΌ: ${e.affected_files.map(f => `<code style="background: var(--bg-crust); padding: 2px 4px; border-radius: 4px;">${escapeHtml(f)}</code>`).join(' ')}
</div>
` : ''}
</div>
`;
});
} catch (err) {
listEl.innerHTML = `<p style="color: var(--red); text-align: center; padding: 20px 0;">μ§μ κ²μ μ€ μ€ν¨: ${err.message}</p>`;
}
}
function showLoading(show, text = '') {
const overlay = document.getElementById('loadingOverlay');
const textEl = document.getElementById('loadingText');
if (text) textEl.textContent = text;
if (show) {
overlay.classList.add('visible');
} else {
overlay.classList.remove('visible');
}
}
function escapeHtml(str) {
if (!str) return '';
return str.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
ipcRenderer.on('switch-tab', (event, tabId) => {
switchTab(tabId);
});
</script>
</body>
</html>
|