()
| 4 | import { initChat, showWelcome } from "./chat.js"; |
| 5 | |
| 6 | async function init() { |
| 7 | try { |
| 8 | const config = await loadConfig(); |
| 9 | |
| 10 | // Set Pack Name & Description |
| 11 | const elName = document.getElementById("pack-name"); |
| 12 | const elDesc = document.getElementById("pack-desc"); |
| 13 | if (elName) elName.textContent = config.name || "Skills Pack"; |
| 14 | if (elDesc) elDesc.textContent = config.description || ""; |
| 15 | document.title = config.name || "Skills Pack"; |
| 16 | |
| 17 | // Set Sidebar Skills list |
| 18 | const skillsList = document.getElementById("skills-list"); |
| 19 | if (skillsList && config.skills) { |
| 20 | skillsList.innerHTML = config.skills |
| 21 | .map( |
| 22 | (s) => |
| 23 | `<li><div class="skill-name">${s.name}</div><div class="skill-desc">${s.description}</div></li>`, |
| 24 | ) |
| 25 | .join(""); |
| 26 | } |
| 27 | |
| 28 | // Pre-fill prompt if exactly one |
| 29 | if (config.prompts && config.prompts.length === 1) { |
| 30 | const input = document.getElementById("user-input"); |
| 31 | if (input) { |
| 32 | input.value = config.prompts[0]; |
| 33 | input.style.height = "auto"; |
| 34 | input.style.height = Math.min(input.scrollHeight, 120) + "px"; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | showWelcome(config); |
| 39 | } catch (err) { |
| 40 | console.error("Initialization Failed:", err); |
| 41 | } |
| 42 | |
| 43 | initApiKeyDialog(); |
| 44 | initChatAppsDialog(); |
| 45 | |
| 46 | try { |
| 47 | await initChat(); |
| 48 | } catch (err) { |
| 49 | console.error("Chat initialization failed:", err); |
| 50 | } |
| 51 | |
| 52 | updateApiKeyButton(); |
| 53 | updateChatAppsButton(); |
| 54 | } |
| 55 | |
| 56 | // Start application |
| 57 | init(); |
no test coverage detected