| 25 | }; |
| 26 | |
| 27 | class IcssDebugServer { |
| 28 | constructor() { |
| 29 | debugLog('🚀 Initializing iCSS Debug Server'); |
| 30 | |
| 31 | this.server = new Server( |
| 32 | { |
| 33 | name: 'icss-debug-server', |
| 34 | version: '1.0.0', |
| 35 | }, |
| 36 | { |
| 37 | capabilities: { |
| 38 | tools: {}, |
| 39 | }, |
| 40 | } |
| 41 | ); |
| 42 | |
| 43 | this.transport = null; |
| 44 | this.db = null; |
| 45 | this.searchEngine = null; |
| 46 | this.isReady = false; |
| 47 | this.dbInitFailed = false; |
| 48 | |
| 49 | this.setupDatabase(); |
| 50 | this.setupHandlers(); |
| 51 | } |
| 52 | |
| 53 | setupDatabase() { |
| 54 | debugLog('📂 Setting up database connection...'); |
| 55 | const dbPath = path.join(__dirname, 'data', 'icss.db'); |
| 56 | debugLog(`📍 Database path: ${dbPath}`); |
| 57 | |
| 58 | this.db = new Database.Database(dbPath, (err) => { |
| 59 | if (err) { |
| 60 | console.error('❌ Error opening database:', err); |
| 61 | this.dbInitFailed = true; |
| 62 | } else { |
| 63 | debugLog('✅ Connected to SQLite database'); |
| 64 | this.loadSearchIndex(); |
| 65 | } |
| 66 | }); |
| 67 | } |
| 68 | |
| 69 | loadSearchIndex() { |
| 70 | debugLog('🔍 Loading search index...'); |
| 71 | |
| 72 | const query = ` |
| 73 | SELECT |
| 74 | i.*, |
| 75 | GROUP_CONCAT(DISTINCT al.label) as tags, |
| 76 | GROUP_CONCAT(DISTINCT al.category) as categories, |
| 77 | GROUP_CONCAT(DISTINCT al.weight) as weights, |
| 78 | GROUP_CONCAT(DISTINCT lc.description) as tag_descriptions |
| 79 | FROM issues i |
| 80 | LEFT JOIN article_labels al ON i.number = al.issue_number |
| 81 | LEFT JOIN label_categories lc ON al.label = lc.label |
| 82 | GROUP BY i.number |
| 83 | `; |
| 84 |
nothing calls this directly
no outgoing calls
no test coverage detected