adhdev 0.1.51 → 0.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +390 -40
- package/package.json +1 -1
- package/providers/_builtin/ide/antigravity/scripts/read_chat.js +22 -0
- package/providers/_builtin/ide/kiro/provider.js +25 -1
- package/providers/_builtin/ide/kiro/scripts/focus_editor.js +20 -0
- package/providers/_builtin/ide/kiro/scripts/open_panel.js +47 -0
- package/providers/_builtin/ide/kiro/scripts/resolve_action.js +54 -0
- package/providers/_builtin/ide/kiro/scripts/send_message.js +29 -0
- package/providers/_builtin/ide/kiro/scripts/webview_list_models.js +39 -0
- package/providers/_builtin/ide/kiro/scripts/webview_list_modes.js +39 -0
- package/providers/_builtin/ide/kiro/scripts/webview_list_sessions.js +21 -0
- package/providers/_builtin/ide/kiro/scripts/webview_new_session.js +34 -0
- package/providers/_builtin/ide/kiro/scripts/webview_read_chat.js +68 -0
- package/providers/_builtin/ide/kiro/scripts/webview_set_mode.js +15 -0
- package/providers/_builtin/ide/kiro/scripts/webview_set_model.js +15 -0
- package/providers/_builtin/ide/kiro/scripts/webview_switch_session.js +26 -0
- package/providers/_builtin/ide/pearai/provider.js +27 -1
- package/providers/_builtin/ide/pearai/scripts/focus_editor.js +20 -0
- package/providers/_builtin/ide/pearai/scripts/open_panel.js +46 -0
- package/providers/_builtin/ide/pearai/scripts/resolve_action.js +54 -0
- package/providers/_builtin/ide/pearai/scripts/send_message.js +29 -0
- package/providers/_builtin/ide/pearai/scripts/webview_list_models.js +43 -0
- package/providers/_builtin/ide/pearai/scripts/webview_list_modes.js +35 -0
- package/providers/_builtin/ide/pearai/scripts/webview_new_session.js +21 -0
- package/providers/_builtin/ide/pearai/scripts/webview_read_chat.js +92 -0
- package/providers/_builtin/ide/pearai/scripts/webview_resolve_action.js +59 -0
- package/providers/_builtin/ide/pearai/scripts/webview_set_mode.js +36 -0
- package/providers/_builtin/ide/pearai/scripts/webview_set_model.js +36 -0
- package/providers/_builtin/ide/trae/provider.js +22 -1
- package/providers/_builtin/ide/trae/scripts/focus_editor.js +20 -0
- package/providers/_builtin/ide/trae/scripts/list_chats.js +24 -0
- package/providers/_builtin/ide/trae/scripts/list_models.js +39 -0
- package/providers/_builtin/ide/trae/scripts/list_modes.js +39 -0
- package/providers/_builtin/ide/trae/scripts/new_session.js +30 -0
- package/providers/_builtin/ide/trae/scripts/open_panel.js +44 -0
- package/providers/_builtin/ide/trae/scripts/read_chat.js +113 -0
- package/providers/_builtin/ide/trae/scripts/resolve_action.js +54 -0
- package/providers/_builtin/ide/trae/scripts/send_message.js +19 -0
- package/providers/_builtin/ide/trae/scripts/set_mode.js +15 -0
- package/providers/_builtin/ide/trae/scripts/set_model.js +15 -0
- package/providers/_builtin/ide/trae/scripts/switch_session.js +23 -0
- package/providers/_builtin/ide/windsurf/provider.js +12 -0
- package/providers/_builtin/ide/windsurf/scripts/list_models.js +39 -0
- package/providers/_builtin/ide/windsurf/scripts/list_modes.js +39 -0
- package/providers/_builtin/ide/windsurf/scripts/set_mode.js +15 -0
- package/providers/_builtin/ide/windsurf/scripts/set_model.js +15 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cline — list_modes
|
|
3
|
+
* 모드 selector에서 사용 가능한 모드 목록 + 현재 모드 반환
|
|
4
|
+
* → { modes: string[], current: string }
|
|
5
|
+
*/
|
|
6
|
+
(async () => {
|
|
7
|
+
try {
|
|
8
|
+
const inner = document.querySelector('iframe');
|
|
9
|
+
const doc = inner?.contentDocument || inner?.contentWindow?.document;
|
|
10
|
+
if (!doc) return JSON.stringify({ modes: [], current: '', error: 'no doc' });
|
|
11
|
+
|
|
12
|
+
// 현재 모드
|
|
13
|
+
const trigger = doc.querySelector('[data-testid="mode-selector-trigger"], [data-testid="mode-switch"]');
|
|
14
|
+
if (!trigger) return JSON.stringify({ modes: [], current: '', error: 'no mode trigger' });
|
|
15
|
+
const current = (trigger.textContent || '').trim();
|
|
16
|
+
|
|
17
|
+
// 드롭다운 열기
|
|
18
|
+
trigger.click();
|
|
19
|
+
await new Promise(r => setTimeout(r, 300));
|
|
20
|
+
|
|
21
|
+
// 옵션 수집
|
|
22
|
+
const options = doc.querySelectorAll('[data-testid*="mode-option"], [role="option"], [class*="dropdown"] [class*="item"], [class*="listbox"] [class*="option"]');
|
|
23
|
+
const modes = [];
|
|
24
|
+
for (const opt of options) {
|
|
25
|
+
const text = (opt.textContent || '').trim();
|
|
26
|
+
if (text && text.length > 1 && text.length < 50) modes.push(text);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 닫기
|
|
30
|
+
doc.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
|
|
31
|
+
if (trigger.click) trigger.click(); // fallback close
|
|
32
|
+
|
|
33
|
+
return JSON.stringify({ modes: [...new Set(modes)], current });
|
|
34
|
+
} catch (e) { return JSON.stringify({ modes: [], current: '', error: e.message }); }
|
|
35
|
+
})()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PearAI — webview_new_session (webview iframe 내부에서 실행)
|
|
3
|
+
*
|
|
4
|
+
* "Start New Task" 버튼 클릭.
|
|
5
|
+
* PearAI Agent(Roo Code/Cline 기반)는 Task 단위로 세션 관리.
|
|
6
|
+
*/
|
|
7
|
+
(() => {
|
|
8
|
+
try {
|
|
9
|
+
const buttons = document.querySelectorAll('button, [role="button"]');
|
|
10
|
+
for (const btn of buttons) {
|
|
11
|
+
const text = (btn.textContent || '').trim();
|
|
12
|
+
if (text.includes('Start New Task') || text.includes('New Task')) {
|
|
13
|
+
btn.click();
|
|
14
|
+
return JSON.stringify({ created: true, method: 'button' });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return JSON.stringify({ created: false, error: 'New Task button not found' });
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return JSON.stringify({ created: false, error: e.message });
|
|
20
|
+
}
|
|
21
|
+
})()
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PearAI — webview_read_chat (webview iframe 내부에서 실행)
|
|
3
|
+
*
|
|
4
|
+
* PearAI는 Roo Code / Cline 기반의 Agent 패널을 사용.
|
|
5
|
+
* React로 렌더링된 DOM에서 메시지를 파싱.
|
|
6
|
+
*
|
|
7
|
+
* DOM 단서:
|
|
8
|
+
* - textarea.chat-text-area: 입력 필드
|
|
9
|
+
* - Task: ... : 유저 메시지
|
|
10
|
+
* - API Request 등: 시스템 메시지
|
|
11
|
+
*
|
|
12
|
+
* 반환: ReadChatResult { id, status, messages, inputContent? }
|
|
13
|
+
*/
|
|
14
|
+
(() => {
|
|
15
|
+
try {
|
|
16
|
+
const messages = [];
|
|
17
|
+
|
|
18
|
+
// 메시지 블록 찾기 — 다양한 셀렉터 시도
|
|
19
|
+
// Cline/Roo Code 기반이므로 유사한 구조
|
|
20
|
+
const allText = document.body?.textContent || '';
|
|
21
|
+
|
|
22
|
+
// Task 헤더에서 유저 메시지
|
|
23
|
+
const taskEl = document.querySelector('[class*="task-header"], [class*="TaskHeader"]');
|
|
24
|
+
if (taskEl) {
|
|
25
|
+
const taskText = taskEl.textContent?.trim() || '';
|
|
26
|
+
if (taskText) {
|
|
27
|
+
messages.push({ role: 'user', content: taskText.replace(/^Task:\s*/i, ''), index: 0 });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 채팅 메시지 영역 파싱 — 공통 클래스
|
|
32
|
+
const chatMessages = document.querySelectorAll('[class*="chat-row"], [class*="ChatRow"], [class*="message-row"], [class*="MessageRow"]');
|
|
33
|
+
chatMessages.forEach((msg, idx) => {
|
|
34
|
+
const text = msg.textContent?.trim() || '';
|
|
35
|
+
if (!text) return;
|
|
36
|
+
|
|
37
|
+
// role 판정 — 클래스명이나 아이콘으로
|
|
38
|
+
const isUser = msg.querySelector('[class*="user"]') != null || msg.classList.toString().includes('user');
|
|
39
|
+
messages.push({
|
|
40
|
+
role: isUser ? 'user' : 'assistant',
|
|
41
|
+
content: text.substring(0, 2000),
|
|
42
|
+
index: idx,
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// 메시지가 없으면 전체 텍스트에서 추출
|
|
47
|
+
if (messages.length === 0 && allText.length > 50) {
|
|
48
|
+
// Task: 패턴 찾기
|
|
49
|
+
const taskMatch = allText.match(/Task:\s*(.+?)(?:\d+[\d.,]*k|\d+\s*$)/s);
|
|
50
|
+
if (taskMatch) {
|
|
51
|
+
messages.push({ role: 'user', content: taskMatch[1].trim().substring(0, 500), index: 0 });
|
|
52
|
+
}
|
|
53
|
+
// AI 응답 찾기 (간략화)
|
|
54
|
+
const bodyContent = allText.substring(0, 2000);
|
|
55
|
+
if (bodyContent.includes('API Request') || bodyContent.includes('Initial Checkpoint')) {
|
|
56
|
+
// 응답이 있음을 표시
|
|
57
|
+
messages.push({ role: 'assistant', content: '(response in progress or completed)', index: 1 });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 상태 감지
|
|
62
|
+
let status = 'idle';
|
|
63
|
+
const cancelBtn = document.querySelector('button[class*="cancel"], [aria-label*="cancel" i]');
|
|
64
|
+
if (cancelBtn && cancelBtn.offsetWidth > 0 && cancelBtn.textContent?.toLowerCase().includes('cancel')) {
|
|
65
|
+
status = 'generating';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// API Request... (로딩) → generating
|
|
69
|
+
const loadingEl = document.querySelector('[class*="loading"], [class*="spinner"]');
|
|
70
|
+
if (loadingEl && loadingEl.offsetWidth > 0) {
|
|
71
|
+
status = 'generating';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// "Retrying" → error/generating
|
|
75
|
+
if (allText.includes('Retrying in') || allText.includes('Retry attempt')) {
|
|
76
|
+
status = 'generating';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 입력 필드
|
|
80
|
+
const textarea = document.querySelector('textarea[placeholder*="Type"], textarea.chat-text-area, textarea');
|
|
81
|
+
const inputContent = textarea ? textarea.value || textarea.textContent?.trim() : '';
|
|
82
|
+
|
|
83
|
+
return JSON.stringify({
|
|
84
|
+
id: 'pearai-agent',
|
|
85
|
+
status,
|
|
86
|
+
messages,
|
|
87
|
+
inputContent: inputContent || undefined,
|
|
88
|
+
});
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
|
|
91
|
+
}
|
|
92
|
+
})()
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PearAI — webview_resolve_action
|
|
3
|
+
*
|
|
4
|
+
* PearAI Agent(Roo Code 기반)는 승인/거절 버튼을 webview 내부에 렌더링함.
|
|
5
|
+
* 버튼을 찾아 직접 click() 이벤트 발생.
|
|
6
|
+
*
|
|
7
|
+
* 파라미터: ${ BUTTON_TEXT }
|
|
8
|
+
*/
|
|
9
|
+
(() => {
|
|
10
|
+
try {
|
|
11
|
+
const want = ${ BUTTON_TEXT };
|
|
12
|
+
const wantNorm = (want || '').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
13
|
+
|
|
14
|
+
function norm(t) { return (t || '').replace(/\s+/g, ' ').trim().toLowerCase(); }
|
|
15
|
+
|
|
16
|
+
function matches(el) {
|
|
17
|
+
const t = norm(el.textContent);
|
|
18
|
+
if (!t || t.length > 80) return false;
|
|
19
|
+
if (t === wantNorm) return true;
|
|
20
|
+
if (t.indexOf(wantNorm) === 0) return true;
|
|
21
|
+
if (wantNorm.indexOf(t) >= 0 && t.length > 2) return true;
|
|
22
|
+
if (/^(run|approve|allow|accept|yes)\b/.test(wantNorm)) {
|
|
23
|
+
if (/^(run|allow|accept|approve)\b/.test(t)) return true;
|
|
24
|
+
}
|
|
25
|
+
if (/^(reject|deny|no|abort)\b/.test(wantNorm)) {
|
|
26
|
+
if (/^(reject|deny)\b/.test(t)) return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const sel = 'button, [role="button"], .vsc-button';
|
|
32
|
+
const allBtns = [...document.querySelectorAll(sel)].filter(b => b.offsetWidth > 0 && b.offsetHeight > 0);
|
|
33
|
+
|
|
34
|
+
let found = null;
|
|
35
|
+
for (let i = allBtns.length - 1; i >= 0; i--) {
|
|
36
|
+
if (matches(allBtns[i])) { found = allBtns[i]; break; }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (found) {
|
|
40
|
+
found.focus?.();
|
|
41
|
+
const rect = found.getBoundingClientRect();
|
|
42
|
+
const x = rect.left + rect.width / 2;
|
|
43
|
+
const y = rect.top + rect.height / 2;
|
|
44
|
+
for (const type of ['pointerdown', 'mousedown', 'pointerup', 'mouseup', 'click']) {
|
|
45
|
+
found.dispatchEvent(new PointerEvent(type, {
|
|
46
|
+
bubbles: true, cancelable: true, view: window,
|
|
47
|
+
clientX: x, clientY: y, pointerId: 1, pointerType: 'mouse'
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
return JSON.stringify({
|
|
51
|
+
resolved: true,
|
|
52
|
+
clicked: found.textContent || wantNorm
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return JSON.stringify({ resolved: false, error: 'Button not found: ' + wantNorm });
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return JSON.stringify({ resolved: false, error: e.message });
|
|
58
|
+
}
|
|
59
|
+
})()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cline — set_mode
|
|
3
|
+
* 모드 selector에서 지정된 모드 선택
|
|
4
|
+
* ${MODE} → JSON.stringify(modeName)
|
|
5
|
+
* → { success: boolean }
|
|
6
|
+
*/
|
|
7
|
+
(async () => {
|
|
8
|
+
try {
|
|
9
|
+
const inner = document.querySelector('iframe');
|
|
10
|
+
const doc = inner?.contentDocument || inner?.contentWindow?.document;
|
|
11
|
+
if (!doc) return JSON.stringify({ success: false, error: 'no doc' });
|
|
12
|
+
|
|
13
|
+
const target = ${MODE};
|
|
14
|
+
const trigger = doc.querySelector('[data-testid="mode-selector-trigger"], [data-testid="mode-switch"]');
|
|
15
|
+
if (!trigger) return JSON.stringify({ success: false, error: 'no mode trigger' });
|
|
16
|
+
|
|
17
|
+
// 드롭다운 열기
|
|
18
|
+
trigger.click();
|
|
19
|
+
await new Promise(r => setTimeout(r, 300));
|
|
20
|
+
|
|
21
|
+
// 옵션에서 타겟 모드 찾기
|
|
22
|
+
const options = doc.querySelectorAll('[data-testid*="mode-option"], [role="option"], [class*="dropdown"] [class*="item"], [class*="listbox"] [class*="option"]');
|
|
23
|
+
for (const opt of options) {
|
|
24
|
+
const text = (opt.textContent || '').trim();
|
|
25
|
+
if (text === target || text.toLowerCase().includes(target.toLowerCase())) {
|
|
26
|
+
opt.click();
|
|
27
|
+
await new Promise(r => setTimeout(r, 200));
|
|
28
|
+
return JSON.stringify({ success: true, mode: text });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 닫기
|
|
33
|
+
doc.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
|
|
34
|
+
return JSON.stringify({ success: false, error: 'mode not found: ' + target });
|
|
35
|
+
} catch (e) { return JSON.stringify({ success: false, error: e.message }); }
|
|
36
|
+
})()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cline — set_model
|
|
3
|
+
* 드롭다운에서 지정된 모델 선택
|
|
4
|
+
* ${MODEL} → JSON.stringify(modelName)
|
|
5
|
+
* → { success: boolean }
|
|
6
|
+
*/
|
|
7
|
+
(async () => {
|
|
8
|
+
try {
|
|
9
|
+
const inner = document.querySelector('iframe');
|
|
10
|
+
const doc = inner?.contentDocument || inner?.contentWindow?.document;
|
|
11
|
+
if (!doc) return JSON.stringify({ success: false, error: 'no doc' });
|
|
12
|
+
|
|
13
|
+
const target = ${MODEL};
|
|
14
|
+
const trigger = doc.querySelector('[data-testid="model-selector"], [data-testid*="model-dropdown"], [data-testid="dropdown-trigger"]');
|
|
15
|
+
if (!trigger) return JSON.stringify({ success: false, error: 'no model trigger' });
|
|
16
|
+
|
|
17
|
+
// 드롭다운 열기
|
|
18
|
+
trigger.click();
|
|
19
|
+
await new Promise(r => setTimeout(r, 300));
|
|
20
|
+
|
|
21
|
+
// 옵션에서 타겟 모델 찾기
|
|
22
|
+
const options = doc.querySelectorAll('[data-testid*="dropdown-option"], [role="option"], [class*="dropdown"] [class*="item"], [class*="listbox"] [class*="option"]');
|
|
23
|
+
for (const opt of options) {
|
|
24
|
+
const text = (opt.textContent || '').trim();
|
|
25
|
+
if (text === target || text.includes(target)) {
|
|
26
|
+
opt.click();
|
|
27
|
+
await new Promise(r => setTimeout(r, 200));
|
|
28
|
+
return JSON.stringify({ success: true, model: text });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 닫기
|
|
33
|
+
doc.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
|
|
34
|
+
return JSON.stringify({ success: false, error: 'model not found: ' + target });
|
|
35
|
+
} catch (e) { return JSON.stringify({ success: false, error: e.message }); }
|
|
36
|
+
})()
|
|
@@ -43,7 +43,7 @@ module.exports = {
|
|
|
43
43
|
},
|
|
44
44
|
|
|
45
45
|
inputMethod: 'cdp-type-and-send',
|
|
46
|
-
inputSelector: '[contenteditable="true"][role="textbox"]',
|
|
46
|
+
inputSelector: '.chat-input-v2-input-box-editable, [contenteditable="true"][role="textbox"]',
|
|
47
47
|
|
|
48
48
|
scripts: {
|
|
49
49
|
readChat() { return loadScript('read_chat.js'); },
|
|
@@ -58,5 +58,26 @@ module.exports = {
|
|
|
58
58
|
const s = loadScript('resolve_action.js');
|
|
59
59
|
return s ? s.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText)) : null;
|
|
60
60
|
},
|
|
61
|
+
openPanel() { return loadScript('open_panel.js'); },
|
|
62
|
+
focusEditor() { return loadScript('focus_editor.js'); },
|
|
63
|
+
// 세션 관리
|
|
64
|
+
newSession() { return loadScript('new_session.js'); },
|
|
65
|
+
listSessions() { return loadScript('list_chats.js'); },
|
|
66
|
+
switchSession(sessionId) {
|
|
67
|
+
const s = loadScript('switch_session.js');
|
|
68
|
+
return s ? s.replace(/\$\{\s*SESSION_ID\s*\}/g, JSON.stringify(sessionId)) : null;
|
|
69
|
+
},
|
|
70
|
+
listModels() { return loadScript('list_models.js'); },
|
|
71
|
+
setModel(params) {
|
|
72
|
+
const model = typeof params === 'string' ? params : params?.model;
|
|
73
|
+
const s = loadScript('set_model.js');
|
|
74
|
+
return s ? s.replace(/\$\{\s*MODEL\s*\}/g, JSON.stringify(model)) : null;
|
|
75
|
+
},
|
|
76
|
+
listModes() { return loadScript('list_modes.js'); },
|
|
77
|
+
setMode(params) {
|
|
78
|
+
const mode = typeof params === 'string' ? params : params?.mode;
|
|
79
|
+
const s = loadScript('set_mode.js');
|
|
80
|
+
return s ? s.replace(/\$\{\s*MODE\s*\}/g, JSON.stringify(mode)) : null;
|
|
81
|
+
},
|
|
61
82
|
},
|
|
62
83
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor v1 — focus_editor
|
|
3
|
+
*
|
|
4
|
+
* CURSOR.md 4-5: 셀렉터 우선순위
|
|
5
|
+
* [contenteditable="true"][role="textbox"]
|
|
6
|
+
* → .chat-input textarea
|
|
7
|
+
* → .composer-input
|
|
8
|
+
* → textarea
|
|
9
|
+
*
|
|
10
|
+
* 최종 확인: 2026-03-06
|
|
11
|
+
*/
|
|
12
|
+
(() => {
|
|
13
|
+
const editor = document.querySelector('[contenteditable="true"][role="textbox"]')
|
|
14
|
+
|| document.querySelector('.chat-input textarea')
|
|
15
|
+
|| document.querySelector('.composer-input')
|
|
16
|
+
|| document.querySelector('textarea.native-input')
|
|
17
|
+
|| document.querySelector('textarea');
|
|
18
|
+
if (editor) { editor.focus(); return 'focused'; }
|
|
19
|
+
return 'no editor found';
|
|
20
|
+
})()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trae — list_chats
|
|
3
|
+
*
|
|
4
|
+
* Trae 메인 DOM에서 탭 / 세션 목록 가져오기.
|
|
5
|
+
*/
|
|
6
|
+
(() => {
|
|
7
|
+
try {
|
|
8
|
+
const tabs = document.querySelectorAll('.chat-tab-header, [class*="tab-item"], [class*="TabItem"]');
|
|
9
|
+
if (tabs.length === 0) return JSON.stringify({ sessions: [] });
|
|
10
|
+
|
|
11
|
+
const sessions = Array.from(tabs).map((tab, i) => {
|
|
12
|
+
const title = (tab.textContent || '').replace('✕', '').trim();
|
|
13
|
+
const active = tab.classList.contains('active') ||
|
|
14
|
+
tab.getAttribute('aria-selected') === 'true' ||
|
|
15
|
+
(tab.className || '').toLowerCase().includes('active');
|
|
16
|
+
return { id: String(i), title, active };
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// 탭 목록이 보이지 않으면 사이드바의 히스토리 버튼 확인
|
|
20
|
+
return JSON.stringify({ sessions });
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return JSON.stringify({ error: e.message, sessions: [] });
|
|
23
|
+
}
|
|
24
|
+
})()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic fallback — list_models
|
|
3
|
+
*/
|
|
4
|
+
(() => {
|
|
5
|
+
try {
|
|
6
|
+
const models = [];
|
|
7
|
+
let current = '';
|
|
8
|
+
|
|
9
|
+
// Try generic Model string from select/button
|
|
10
|
+
const sel = document.querySelectorAll('select, [class*="model"], [id*="model"]');
|
|
11
|
+
for (const el of sel) {
|
|
12
|
+
const txt = (el.textContent || '').trim();
|
|
13
|
+
if (txt && /claude|gpt|gemini|sonnet|opus/i.test(txt)) {
|
|
14
|
+
if (txt.length < 50) {
|
|
15
|
+
models.push(txt);
|
|
16
|
+
if (!current) current = txt;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (models.length === 0) {
|
|
22
|
+
const btns = document.querySelectorAll('button');
|
|
23
|
+
for (const b of btns) {
|
|
24
|
+
const txt = (b.textContent || '').trim();
|
|
25
|
+
if (txt && /claude|gpt|gemini|sonnet/i.test(txt) && txt.length < 30) {
|
|
26
|
+
models.push(txt);
|
|
27
|
+
current = txt;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return JSON.stringify({
|
|
33
|
+
models: [...new Set(models)],
|
|
34
|
+
current: current || 'Default'
|
|
35
|
+
});
|
|
36
|
+
} catch (e) {
|
|
37
|
+
return JSON.stringify({ models: [], current: '', error: e.message });
|
|
38
|
+
}
|
|
39
|
+
})()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic fallback — list_models
|
|
3
|
+
*/
|
|
4
|
+
(() => {
|
|
5
|
+
try {
|
|
6
|
+
const models = [];
|
|
7
|
+
let current = '';
|
|
8
|
+
|
|
9
|
+
// Try generic Model string from select/button
|
|
10
|
+
const sel = document.querySelectorAll('select, [class*="model"], [id*="model"]');
|
|
11
|
+
for (const el of sel) {
|
|
12
|
+
const txt = (el.textContent || '').trim();
|
|
13
|
+
if (txt && /claude|gpt|gemini|sonnet|opus/i.test(txt)) {
|
|
14
|
+
if (txt.length < 50) {
|
|
15
|
+
models.push(txt);
|
|
16
|
+
if (!current) current = txt;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (models.length === 0) {
|
|
22
|
+
const btns = document.querySelectorAll('button');
|
|
23
|
+
for (const b of btns) {
|
|
24
|
+
const txt = (b.textContent || '').trim();
|
|
25
|
+
if (txt && /claude|gpt|gemini|sonnet/i.test(txt) && txt.length < 30) {
|
|
26
|
+
models.push(txt);
|
|
27
|
+
current = txt;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return JSON.stringify({
|
|
33
|
+
models: [...new Set(models)],
|
|
34
|
+
current: current || 'Default'
|
|
35
|
+
});
|
|
36
|
+
} catch (e) {
|
|
37
|
+
return JSON.stringify({ models: [], current: '', error: e.message });
|
|
38
|
+
}
|
|
39
|
+
})()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trae — new_session
|
|
3
|
+
*
|
|
4
|
+
* "New Task" 생성 (⌃⌘N 단축키 또는 버튼 클릭).
|
|
5
|
+
* Trae는 메인 DOM에서 접근 가능.
|
|
6
|
+
*/
|
|
7
|
+
(() => {
|
|
8
|
+
try {
|
|
9
|
+
// 버튼 찾기
|
|
10
|
+
const buttons = document.querySelectorAll('button, [role="button"], .action-item a');
|
|
11
|
+
for (const btn of buttons) {
|
|
12
|
+
const text = (btn.textContent || '').trim();
|
|
13
|
+
const label = (btn.getAttribute('aria-label') || '').toLowerCase();
|
|
14
|
+
if (text.includes('New Task') || label.includes('new task') || label.includes('new chat')) {
|
|
15
|
+
btn.click();
|
|
16
|
+
return JSON.stringify({ created: true, method: 'button' });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 단축키 폴백: ⌃⌘N
|
|
21
|
+
document.dispatchEvent(new KeyboardEvent('keydown', {
|
|
22
|
+
key: 'n', code: 'KeyN', keyCode: 78,
|
|
23
|
+
metaKey: true, ctrlKey: true,
|
|
24
|
+
bubbles: true, cancelable: true,
|
|
25
|
+
}));
|
|
26
|
+
return JSON.stringify({ created: true, method: 'shortcut' });
|
|
27
|
+
} catch (e) {
|
|
28
|
+
return JSON.stringify({ created: false, error: e.message });
|
|
29
|
+
}
|
|
30
|
+
})()
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trae — open_panel
|
|
3
|
+
*
|
|
4
|
+
* Trae AI 채팅 패널 열기.
|
|
5
|
+
* "TRAE" 버튼 또는 ⌘L 단축키로 열기.
|
|
6
|
+
*
|
|
7
|
+
* 반환: 'visible' | 'opened' | 'error: ...'
|
|
8
|
+
*/
|
|
9
|
+
(() => {
|
|
10
|
+
try {
|
|
11
|
+
// 1. 이미 열려 있는지 확인
|
|
12
|
+
const sidebar = document.getElementById('workbench.parts.auxiliarybar');
|
|
13
|
+
if (sidebar && sidebar.offsetWidth > 0 && sidebar.offsetHeight > 0) {
|
|
14
|
+
return 'visible';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 2. "TRAE" 버튼 클릭 시도
|
|
18
|
+
const toggleBtns = Array.from(document.querySelectorAll('li.action-item a, button, [role="button"]'));
|
|
19
|
+
for (const btn of toggleBtns) {
|
|
20
|
+
const label = (btn.getAttribute('aria-label') || '');
|
|
21
|
+
if (label === 'TRAE' || label.toLowerCase().includes('toggle secondary') ||
|
|
22
|
+
label.toLowerCase().includes('toggle auxiliary')) {
|
|
23
|
+
btn.click();
|
|
24
|
+
return 'opened (toggle)';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 3. Cmd+L 단축키 폴백 (Trae 기본 단축키)
|
|
29
|
+
document.dispatchEvent(new KeyboardEvent('keydown', {
|
|
30
|
+
key: 'l', code: 'KeyL', keyCode: 76,
|
|
31
|
+
metaKey: true, ctrlKey: false,
|
|
32
|
+
bubbles: true, cancelable: true,
|
|
33
|
+
}));
|
|
34
|
+
document.dispatchEvent(new KeyboardEvent('keyup', {
|
|
35
|
+
key: 'l', code: 'KeyL', keyCode: 76,
|
|
36
|
+
metaKey: true, ctrlKey: false,
|
|
37
|
+
bubbles: true, cancelable: true,
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
return 'opened (⌘L)';
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return 'error: ' + e.message;
|
|
43
|
+
}
|
|
44
|
+
})()
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trae — read_chat
|
|
3
|
+
*
|
|
4
|
+
* Trae는 메인 DOM에서 직접 채팅 내용에 접근 가능.
|
|
5
|
+
* 채팅 턴은 .chat-turn 요소로 구분.
|
|
6
|
+
* 유저: .user-chat-bubble-request__content-wrapper
|
|
7
|
+
* 어시스턴트: .assistant-chat-turn-content .chat-markdown
|
|
8
|
+
*
|
|
9
|
+
* 반환: ReadChatResult { id, status, messages, title?, inputContent?, activeModal? }
|
|
10
|
+
*/
|
|
11
|
+
(() => {
|
|
12
|
+
try {
|
|
13
|
+
const auxbar = document.getElementById('workbench.parts.auxiliarybar');
|
|
14
|
+
if (!auxbar || auxbar.offsetWidth === 0) {
|
|
15
|
+
return JSON.stringify({ id: '', status: 'idle', messages: [] });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ─── 1. 메시지 수집 ───
|
|
19
|
+
const messages = [];
|
|
20
|
+
const turns = auxbar.querySelectorAll('.chat-turn');
|
|
21
|
+
|
|
22
|
+
turns.forEach((turn, idx) => {
|
|
23
|
+
// User message
|
|
24
|
+
const userBubble = turn.querySelector('.user-chat-bubble-request__content-wrapper');
|
|
25
|
+
if (userBubble) {
|
|
26
|
+
messages.push({
|
|
27
|
+
role: 'user',
|
|
28
|
+
content: userBubble.textContent.trim(),
|
|
29
|
+
index: idx,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Assistant message
|
|
34
|
+
const assistantEl = turn.querySelector('.assistant-chat-turn-content');
|
|
35
|
+
if (assistantEl) {
|
|
36
|
+
const mdBlocks = assistantEl.querySelectorAll('.chat-markdown-p, .chat-markdown pre');
|
|
37
|
+
let content = '';
|
|
38
|
+
if (mdBlocks.length > 0) {
|
|
39
|
+
content = Array.from(mdBlocks).map(b => b.textContent.trim()).join('\n');
|
|
40
|
+
} else {
|
|
41
|
+
content = assistantEl.textContent.trim();
|
|
42
|
+
}
|
|
43
|
+
if (content) {
|
|
44
|
+
messages.push({
|
|
45
|
+
role: 'assistant',
|
|
46
|
+
content: content,
|
|
47
|
+
index: idx,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// ─── 2. 상태 감지 ───
|
|
54
|
+
let status = 'idle';
|
|
55
|
+
|
|
56
|
+
// Stop 버튼 존재 → generating
|
|
57
|
+
const stopBtn = auxbar.querySelector('button[class*="stop"], [aria-label*="stop" i], [aria-label*="Stop"]');
|
|
58
|
+
if (stopBtn && stopBtn.offsetWidth > 0) {
|
|
59
|
+
status = 'generating';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// progress bar 활성 → generating
|
|
63
|
+
const progress = auxbar.querySelector('.monaco-progress-container:not(.done)');
|
|
64
|
+
if (progress && progress.offsetWidth > 0) {
|
|
65
|
+
status = 'generating';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// latest-assistant-bar가 가장 정확한 상태 표시 (최종 판정)
|
|
69
|
+
const latestBar = auxbar.querySelector('.latest-assistant-bar');
|
|
70
|
+
if (latestBar) {
|
|
71
|
+
const barText = latestBar.textContent.toLowerCase();
|
|
72
|
+
if (barText.includes('completed') || barText.includes('done')) {
|
|
73
|
+
status = 'idle';
|
|
74
|
+
} else if (barText.includes('thinking') || barText.includes('generating') || barText.includes('running') || barText.includes('searching')) {
|
|
75
|
+
status = 'generating';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ─── 3. 승인 대기 모달 ───
|
|
80
|
+
let activeModal = null;
|
|
81
|
+
const dialogs = auxbar.querySelectorAll('[role="dialog"], .monaco-dialog-box, [class*="approval"], [class*="confirm"]');
|
|
82
|
+
if (dialogs.length > 0) {
|
|
83
|
+
const dialog = dialogs[0];
|
|
84
|
+
const buttons = Array.from(dialog.querySelectorAll('button')).map(b => b.textContent.trim()).filter(Boolean);
|
|
85
|
+
if (buttons.length > 0) {
|
|
86
|
+
activeModal = {
|
|
87
|
+
message: dialog.textContent.trim().substring(0, 200),
|
|
88
|
+
buttons: buttons,
|
|
89
|
+
};
|
|
90
|
+
status = 'waiting_approval';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ─── 4. 입력 필드 내용 ───
|
|
95
|
+
const input = auxbar.querySelector('.chat-input-v2-input-box-editable, [contenteditable="true"]');
|
|
96
|
+
const inputContent = input ? input.textContent.trim() : '';
|
|
97
|
+
|
|
98
|
+
// ─── 5. 세션 ID / 타이틀 ───
|
|
99
|
+
const sessionTab = auxbar.querySelector('[class*="session-tab"], [class*="chat-title"]');
|
|
100
|
+
const title = sessionTab ? sessionTab.textContent.trim() : '';
|
|
101
|
+
|
|
102
|
+
return JSON.stringify({
|
|
103
|
+
id: title || 'trae-default',
|
|
104
|
+
status: status,
|
|
105
|
+
messages: messages,
|
|
106
|
+
title: title || undefined,
|
|
107
|
+
inputContent: inputContent || undefined,
|
|
108
|
+
activeModal: activeModal,
|
|
109
|
+
});
|
|
110
|
+
} catch (e) {
|
|
111
|
+
return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
|
|
112
|
+
}
|
|
113
|
+
})()
|