feat: 보드 선택 시 설치된 라이브러리 목록을 AI 시스템 프롬프트에 포함

- _csbFetchLibs(): 보드 선택 시 /api/arduino/libs?fqbn= 호출 후 캐시
- 초기 로드 및 보드 변경 시 자동 갱신
- lang: 선택 시 라이브러리 조회 생략
- boardBlock에 "설치된 라이브러리: ..." 추가 (~113 토큰)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
kim
2026-06-30 17:53:54 +09:00
co-authored by Claude Sonnet 4.6
parent 267441d633
commit 0951368221
+20 -1
View File
@@ -2880,8 +2880,11 @@ function _buildCodeSystemPrompt() {
const _activeCode = (() => { try { const f = codeFiles.find(f => f.id === activeCodeFileId); return f?.model?.getValue() || f?.content || ''; } catch { return ''; } })();
const boardHints = _boardSpecificHints(_activeCode);
const isLangOnly = _csbSelBoard?.fqbn?.startsWith('lang:');
const libBlock = (!isLangOnly && _csbBoardLibs.length)
? `\n설치된 라이브러리: ${_csbBoardLibs.join(', ')}`
: '';
const boardBlock = _csbSelBoard?.fqbn
? `\n## ${isLangOnly ? '코딩 언어' : '대상 보드'}: ${_csbSelBoard.name}${isLangOnly ? '' : ` (${_csbSelBoard.fqbn})`}${boardHints}\n`
? `\n## ${isLangOnly ? '코딩 언어' : '대상 보드'}: ${_csbSelBoard.name}${isLangOnly ? '' : ` (${_csbSelBoard.fqbn})`}${boardHints}${libBlock}\n`
: '';
// 에디터 파일 컨텍스트 — 로컬 폴더와 분리하여 강조
@@ -4803,10 +4806,26 @@ let _csbSelBoard = (() => {
catch { return CSB_BOARD_DEFAULT; }
})();
let _csbSelAllBoards = [];
let _csbBoardLibs = []; // 현재 보드의 설치된 라이브러리 캐시
let _csbBoardLibsFqbn = ''; // 캐시된 fqbn
async function _csbFetchLibs(fqbn) {
if (!fqbn || fqbn.startsWith('lang:')) { _csbBoardLibs = []; _csbBoardLibsFqbn = fqbn; return; }
if (fqbn === _csbBoardLibsFqbn) return;
try {
const data = await api('/api/arduino/libs?fqbn=' + encodeURIComponent(fqbn));
_csbBoardLibs = (data.libs || []).map(l => l.name).filter(Boolean);
_csbBoardLibsFqbn = fqbn;
} catch { _csbBoardLibs = []; }
}
// 초기 로드 시 현재 보드 라이브러리 가져오기
_csbFetchLibs(_csbSelBoard.fqbn);
function _csbBoardSelSave(board) {
_csbSelBoard = board;
try { localStorage.setItem('csb_selected_board', JSON.stringify(board)); } catch {}
_csbFetchLibs(board.fqbn);
const el = document.getElementById('csb-board-sel-name');
if (el) el.textContent = board.name;
const badge = document.getElementById('csb-board-qemu-badge');