Ferrell Synthetic Intelligence commited on
Commit ·
b6522ba
1
Parent(s): 493a8d2
Connect active file to LSP intelligence
Browse files- app.js +17 -1
- index.html +1 -0
app.js
CHANGED
|
@@ -277,7 +277,8 @@ async function startTool(kind, id, label) {
|
|
| 277 |
appendLog('TOOLCHAIN', `${label} ${result.status}.`);
|
| 278 |
if (kind === 'lsp') {
|
| 279 |
const init = await fetch('http://127.0.0.1:4777/api/lsp/request', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id, message: { method: 'initialize', params: { processId: null, rootUri: null, capabilities: {} } } }) });
|
| 280 |
-
|
|
|
|
| 281 |
}
|
| 282 |
} catch (error) {
|
| 283 |
$('#tool-status').textContent = `${label}: unavailable`;
|
|
@@ -285,6 +286,20 @@ async function startTool(kind, id, label) {
|
|
| 285 |
}
|
| 286 |
}
|
| 287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
async function trainingRequest(action, payload = {}) {
|
| 289 |
try {
|
| 290 |
const response = await fetch(`http://127.0.0.1:4777/api/training/${action}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
|
|
@@ -358,6 +373,7 @@ async function boot() {
|
|
| 358 |
document.querySelectorAll('[data-community-tab]').forEach(button => button.onclick = () => renderCommunity(button.dataset.communityTab));
|
| 359 |
$('#community-add').onclick = addCommunityIssue;
|
| 360 |
$('#lsp-button').onclick = () => startTool('lsp', 'typescript', 'TypeScript LSP');
|
|
|
|
| 361 |
$('#dap-button').onclick = () => startTool('dap', 'python-debugpy', 'Python DAP');
|
| 362 |
$('#training-verify').onclick = () => trainingRequest('start', { id: 'verify-release', approved: true });
|
| 363 |
$('#training-stop').onclick = () => trainingRequest('stop');
|
|
|
|
| 277 |
appendLog('TOOLCHAIN', `${label} ${result.status}.`);
|
| 278 |
if (kind === 'lsp') {
|
| 279 |
const init = await fetch('http://127.0.0.1:4777/api/lsp/request', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id, message: { method: 'initialize', params: { processId: null, rootUri: null, capabilities: {} } } }) });
|
| 280 |
+
const initialized = await fetch('http://127.0.0.1:4777/api/lsp/notify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id, message: { method: 'initialized', params: {} } }) });
|
| 281 |
+
appendLog('LSP', init.ok && initialized.ok ? 'initialize handshake completed.' : 'initialize handshake failed.', init.ok && initialized.ok ? '' : 'warning');
|
| 282 |
}
|
| 283 |
} catch (error) {
|
| 284 |
$('#tool-status').textContent = `${label}: unavailable`;
|
|
|
|
| 286 |
}
|
| 287 |
}
|
| 288 |
|
| 289 |
+
async function checkActiveFile() {
|
| 290 |
+
try {
|
| 291 |
+
const content = $('#code').textContent;
|
| 292 |
+
const uri = `file:///workspace/${state.activeFile}`;
|
| 293 |
+
const open = await fetch('http://127.0.0.1:4777/api/lsp/notify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: 'typescript', message: { method: 'textDocument/didOpen', params: { textDocument: { uri, languageId: 'typescript', version: 1, text: content } } } }) });
|
| 294 |
+
if (!open.ok) throw new Error('LSP is not running');
|
| 295 |
+
const response = await fetch('http://127.0.0.1:4777/api/lsp/request', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: 'typescript', message: { method: 'textDocument/completion', params: { textDocument: { uri }, position: { line: 0, character: 0 } } } }) });
|
| 296 |
+
const result = await response.json();
|
| 297 |
+
if (!response.ok) throw new Error(result.error?.message || 'completion request failed');
|
| 298 |
+
const count = result.result?.items?.length ?? result.result?.length ?? 0;
|
| 299 |
+
appendLog('LSP', `Active file analyzed. Completion items returned: ${count}.`);
|
| 300 |
+
} catch (error) { appendLog('LSP', error.message, 'warning'); }
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
async function trainingRequest(action, payload = {}) {
|
| 304 |
try {
|
| 305 |
const response = await fetch(`http://127.0.0.1:4777/api/training/${action}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
|
|
|
|
| 373 |
document.querySelectorAll('[data-community-tab]').forEach(button => button.onclick = () => renderCommunity(button.dataset.communityTab));
|
| 374 |
$('#community-add').onclick = addCommunityIssue;
|
| 375 |
$('#lsp-button').onclick = () => startTool('lsp', 'typescript', 'TypeScript LSP');
|
| 376 |
+
$('#lsp-check').onclick = checkActiveFile;
|
| 377 |
$('#dap-button').onclick = () => startTool('dap', 'python-debugpy', 'Python DAP');
|
| 378 |
$('#training-verify').onclick = () => trainingRequest('start', { id: 'verify-release', approved: true });
|
| 379 |
$('#training-stop').onclick = () => trainingRequest('stop');
|
index.html
CHANGED
|
@@ -68,6 +68,7 @@
|
|
| 68 |
<div id="community-feed" style="font:9px/1.6 ui-monospace,monospace;color:#9fb8ba;margin-top:7px"></div>
|
| 69 |
<div class="section-heading divider">TOOLCHAIN</div>
|
| 70 |
<button id="lsp-button" class="secondary" style="width:100%;padding:6px">START TYPESCRIPT LSP</button>
|
|
|
|
| 71 |
<button id="dap-button" class="secondary" style="width:100%;margin-top:5px;padding:6px">START PYTHON DAP</button>
|
| 72 |
<div id="tool-status" style="color:#718994;font:9px/1.6 ui-monospace,monospace;margin-top:6px">LSP/DAP status unknown.</div>
|
| 73 |
<div class="section-heading divider">TRAINING ROOM</div>
|
|
|
|
| 68 |
<div id="community-feed" style="font:9px/1.6 ui-monospace,monospace;color:#9fb8ba;margin-top:7px"></div>
|
| 69 |
<div class="section-heading divider">TOOLCHAIN</div>
|
| 70 |
<button id="lsp-button" class="secondary" style="width:100%;padding:6px">START TYPESCRIPT LSP</button>
|
| 71 |
+
<button id="lsp-check" class="secondary" style="width:100%;margin-top:5px;padding:6px">CHECK ACTIVE FILE</button>
|
| 72 |
<button id="dap-button" class="secondary" style="width:100%;margin-top:5px;padding:6px">START PYTHON DAP</button>
|
| 73 |
<div id="tool-status" style="color:#718994;font:9px/1.6 ui-monospace,monospace;margin-top:6px">LSP/DAP status unknown.</div>
|
| 74 |
<div class="section-heading divider">TRAINING ROOM</div>
|