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.
Files changed (46) hide show
  1. package/dist/index.js +390 -40
  2. package/package.json +1 -1
  3. package/providers/_builtin/ide/antigravity/scripts/read_chat.js +22 -0
  4. package/providers/_builtin/ide/kiro/provider.js +25 -1
  5. package/providers/_builtin/ide/kiro/scripts/focus_editor.js +20 -0
  6. package/providers/_builtin/ide/kiro/scripts/open_panel.js +47 -0
  7. package/providers/_builtin/ide/kiro/scripts/resolve_action.js +54 -0
  8. package/providers/_builtin/ide/kiro/scripts/send_message.js +29 -0
  9. package/providers/_builtin/ide/kiro/scripts/webview_list_models.js +39 -0
  10. package/providers/_builtin/ide/kiro/scripts/webview_list_modes.js +39 -0
  11. package/providers/_builtin/ide/kiro/scripts/webview_list_sessions.js +21 -0
  12. package/providers/_builtin/ide/kiro/scripts/webview_new_session.js +34 -0
  13. package/providers/_builtin/ide/kiro/scripts/webview_read_chat.js +68 -0
  14. package/providers/_builtin/ide/kiro/scripts/webview_set_mode.js +15 -0
  15. package/providers/_builtin/ide/kiro/scripts/webview_set_model.js +15 -0
  16. package/providers/_builtin/ide/kiro/scripts/webview_switch_session.js +26 -0
  17. package/providers/_builtin/ide/pearai/provider.js +27 -1
  18. package/providers/_builtin/ide/pearai/scripts/focus_editor.js +20 -0
  19. package/providers/_builtin/ide/pearai/scripts/open_panel.js +46 -0
  20. package/providers/_builtin/ide/pearai/scripts/resolve_action.js +54 -0
  21. package/providers/_builtin/ide/pearai/scripts/send_message.js +29 -0
  22. package/providers/_builtin/ide/pearai/scripts/webview_list_models.js +43 -0
  23. package/providers/_builtin/ide/pearai/scripts/webview_list_modes.js +35 -0
  24. package/providers/_builtin/ide/pearai/scripts/webview_new_session.js +21 -0
  25. package/providers/_builtin/ide/pearai/scripts/webview_read_chat.js +92 -0
  26. package/providers/_builtin/ide/pearai/scripts/webview_resolve_action.js +59 -0
  27. package/providers/_builtin/ide/pearai/scripts/webview_set_mode.js +36 -0
  28. package/providers/_builtin/ide/pearai/scripts/webview_set_model.js +36 -0
  29. package/providers/_builtin/ide/trae/provider.js +22 -1
  30. package/providers/_builtin/ide/trae/scripts/focus_editor.js +20 -0
  31. package/providers/_builtin/ide/trae/scripts/list_chats.js +24 -0
  32. package/providers/_builtin/ide/trae/scripts/list_models.js +39 -0
  33. package/providers/_builtin/ide/trae/scripts/list_modes.js +39 -0
  34. package/providers/_builtin/ide/trae/scripts/new_session.js +30 -0
  35. package/providers/_builtin/ide/trae/scripts/open_panel.js +44 -0
  36. package/providers/_builtin/ide/trae/scripts/read_chat.js +113 -0
  37. package/providers/_builtin/ide/trae/scripts/resolve_action.js +54 -0
  38. package/providers/_builtin/ide/trae/scripts/send_message.js +19 -0
  39. package/providers/_builtin/ide/trae/scripts/set_mode.js +15 -0
  40. package/providers/_builtin/ide/trae/scripts/set_model.js +15 -0
  41. package/providers/_builtin/ide/trae/scripts/switch_session.js +23 -0
  42. package/providers/_builtin/ide/windsurf/provider.js +12 -0
  43. package/providers/_builtin/ide/windsurf/scripts/list_models.js +39 -0
  44. package/providers/_builtin/ide/windsurf/scripts/list_modes.js +39 -0
  45. package/providers/_builtin/ide/windsurf/scripts/set_mode.js +15 -0
  46. package/providers/_builtin/ide/windsurf/scripts/set_model.js +15 -0
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Kiro — open_panel
3
+ *
4
+ * Kiro AI 채팅 패널 열기.
5
+ * Secondary Side Bar (#workbench.parts.auxiliarybar)에 위치.
6
+ * "Toggle Secondary Side Bar (⌥⌘B)" 또는 "Kiro" 버튼으로 열기.
7
+ *
8
+ * 반환: 'visible' | 'opened' | 'error: ...'
9
+ */
10
+ (() => {
11
+ try {
12
+ // 1. 이미 열려 있는지 확인
13
+ const sidebar = document.getElementById('workbench.parts.auxiliarybar');
14
+ if (sidebar && sidebar.offsetWidth > 0 && sidebar.offsetHeight > 0) {
15
+ return 'visible';
16
+ }
17
+
18
+ // 2. Toggle 버튼 클릭 시도
19
+ const toggleBtns = Array.from(document.querySelectorAll('li.action-item a, button, [role="button"]'));
20
+ for (const btn of toggleBtns) {
21
+ const label = (btn.getAttribute('aria-label') || '').toLowerCase();
22
+ if (label.includes('toggle secondary') || label.includes('toggle auxiliary') ||
23
+ label === 'kiro' || label.includes('kiro')) {
24
+ if (btn.offsetWidth > 0 || btn.offsetHeight > 0) {
25
+ btn.click();
26
+ return 'opened (toggle)';
27
+ }
28
+ }
29
+ }
30
+
31
+ // 3. Cmd+Shift+I 단축키 폴백 (Kiro 기본 단축키)
32
+ document.dispatchEvent(new KeyboardEvent('keydown', {
33
+ key: 'b', code: 'KeyB', keyCode: 66,
34
+ metaKey: true, altKey: true, ctrlKey: false,
35
+ bubbles: true, cancelable: true,
36
+ }));
37
+ document.dispatchEvent(new KeyboardEvent('keyup', {
38
+ key: 'b', code: 'KeyB', keyCode: 66,
39
+ metaKey: true, altKey: true, ctrlKey: false,
40
+ bubbles: true, cancelable: true,
41
+ }));
42
+
43
+ return 'opened (⌥⌘B)';
44
+ } catch (e) {
45
+ return 'error: ' + e.message;
46
+ }
47
+ })()
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Kiro — resolve_action
3
+ *
4
+ * 승인/거부 버튼 찾기 + 좌표 반환.
5
+ * Kiro의 approval 다이얼로그는 메인 DOM에 표시됨.
6
+ *
7
+ * 파라미터: ${ BUTTON_TEXT }
8
+ */
9
+ (() => {
10
+ const want = ${ BUTTON_TEXT };
11
+ const wantNorm = (want || '').replace(/\s+/g, ' ').trim().toLowerCase();
12
+
13
+ function norm(t) { return (t || '').replace(/\s+/g, ' ').trim().toLowerCase(); }
14
+
15
+ function matches(el) {
16
+ const t = norm(el.textContent);
17
+ if (!t || t.length > 80) return false;
18
+ if (t === wantNorm) return true;
19
+ if (t.indexOf(wantNorm) === 0) return true;
20
+ if (wantNorm.indexOf(t) >= 0 && t.length > 2) return true;
21
+ if (/^(run|approve|allow|accept|yes)\b/.test(wantNorm)) {
22
+ if (/^(run|allow|accept|approve)\b/.test(t)) return true;
23
+ }
24
+ if (/^(reject|deny|no|abort)\b/.test(wantNorm)) {
25
+ if (/^(reject|deny)\b/.test(t)) return true;
26
+ }
27
+ return false;
28
+ }
29
+
30
+ const sel = 'button, [role="button"], .monaco-button';
31
+ const allBtns = [...document.querySelectorAll(sel)].filter(b => {
32
+ if (!b.offsetWidth || !b.getBoundingClientRect().height) return false;
33
+ const rect = b.getBoundingClientRect();
34
+ return rect.y > 0 && rect.y < window.innerHeight;
35
+ });
36
+
37
+ let found = null;
38
+ for (let i = allBtns.length - 1; i >= 0; i--) {
39
+ if (matches(allBtns[i])) { found = allBtns[i]; break; }
40
+ }
41
+
42
+ if (found) {
43
+ const rect = found.getBoundingClientRect();
44
+ return JSON.stringify({
45
+ found: true,
46
+ text: found.textContent?.trim()?.substring(0, 40),
47
+ x: Math.round(rect.x + rect.width / 2),
48
+ y: Math.round(rect.y + rect.height / 2),
49
+ w: Math.round(rect.width),
50
+ h: Math.round(rect.height)
51
+ });
52
+ }
53
+ return JSON.stringify({ found: false, want: wantNorm });
54
+ })()
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Kiro — send_message
3
+ *
4
+ * Kiro의 채팅 입력은 webview iframe 안에 있어 메인 DOM에서 직접 접근 불가.
5
+ * auxbar 하단의 입력 필드 좌표를 계산하여 clickCoords로 반환.
6
+ * 데몬이 CDP Input API로 해당 좌표에 클릭+타이핑+Enter를 수행.
7
+ *
8
+ * 파라미터: ${ MESSAGE }
9
+ */
10
+ (() => {
11
+ try {
12
+ const auxbar = document.getElementById('workbench.parts.auxiliarybar');
13
+ if (!auxbar || auxbar.offsetWidth === 0) {
14
+ return JSON.stringify({ sent: false, error: 'auxbar not found' });
15
+ }
16
+
17
+ const rect = auxbar.getBoundingClientRect();
18
+ const x = Math.round(rect.x + rect.width / 2);
19
+ const y = Math.round(rect.y + rect.height - 80);
20
+
21
+ return JSON.stringify({
22
+ sent: false,
23
+ needsTypeAndSend: true,
24
+ clickCoords: { x, y },
25
+ });
26
+ } catch (e) {
27
+ return JSON.stringify({ sent: false, error: e.message });
28
+ }
29
+ })()
@@ -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,21 @@
1
+ /**
2
+ * Kiro — webview_list_sessions (webview iframe 내부에서 실행)
3
+ *
4
+ * Kiro의 세션 탭 목록을 반환.
5
+ * DOM: .kiro-tabs-item
6
+ */
7
+ (() => {
8
+ try {
9
+ const tabs = document.querySelectorAll('.kiro-tabs-item');
10
+ const sessions = Array.from(tabs).map((tab, i) => {
11
+ const label = tab.querySelector('.kiro-tabs-item-label');
12
+ const title = (label?.textContent || tab.textContent || '').trim();
13
+ const active = tab.classList.contains('active') ||
14
+ tab.getAttribute('aria-selected') === 'true';
15
+ return { id: String(i), title, active };
16
+ });
17
+ return JSON.stringify({ sessions });
18
+ } catch (e) {
19
+ return JSON.stringify({ sessions: [], error: e.message });
20
+ }
21
+ })()
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Kiro — webview_new_session (webview iframe 내부에서 실행)
3
+ *
4
+ * "New Session" 버튼/탭 클릭.
5
+ * Kiro는 탭 바에 + 버튼 또는 "New Session" 액션이 있음.
6
+ */
7
+ (() => {
8
+ try {
9
+ // kiro-icon-button (+ 버튼) 찾기
10
+ const addBtns = document.querySelectorAll('.kiro-icon-button, button, [role="button"]');
11
+ for (const btn of addBtns) {
12
+ const ariaLabel = (btn.getAttribute('aria-label') || '').toLowerCase();
13
+ const title = (btn.getAttribute('title') || '').toLowerCase();
14
+ if (ariaLabel.includes('new') || title.includes('new') ||
15
+ ariaLabel.includes('add') || title.includes('add')) {
16
+ btn.click();
17
+ return JSON.stringify({ created: true, method: 'button' });
18
+ }
19
+ }
20
+
21
+ // Checkpoint > New Session 영역 찾기
22
+ const allText = document.querySelectorAll('*');
23
+ for (const el of allText) {
24
+ if (el.children.length === 0 && (el.textContent || '').trim() === 'New Session') {
25
+ el.click();
26
+ return JSON.stringify({ created: true, method: 'text-click' });
27
+ }
28
+ }
29
+
30
+ return JSON.stringify({ created: false, error: 'New Session button not found' });
31
+ } catch (e) {
32
+ return JSON.stringify({ created: false, error: e.message });
33
+ }
34
+ })()
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Kiro — webview_read_chat (webview iframe 내부에서 실행)
3
+ *
4
+ * Kiro의 채팅 UI는 webview iframe 안에 위치하며,
5
+ * 데몬의 evaluateInWebviewFrame을 통해 실행됨.
6
+ *
7
+ * DOM 구조:
8
+ * .kiro-chat-timeline
9
+ * .kiro-chat-message (유저/어시스턴트 메시지)
10
+ * .kiro-chat-message-meta → .kiro-chat-message-role (발신자)
11
+ * .kiro-chat-message-body → .kiro-chat-message-markdown (내용)
12
+ *
13
+ * 반환: ReadChatResult { id, status, messages, inputContent? }
14
+ */
15
+ (() => {
16
+ try {
17
+ const messages = [];
18
+ const msgElements = document.querySelectorAll('.kiro-chat-message');
19
+
20
+ msgElements.forEach((msg, idx) => {
21
+ const roleMeta = msg.querySelector('.kiro-chat-message-role');
22
+ const roleText = (roleMeta?.textContent || '').trim();
23
+ const isKiro = roleText.toLowerCase() === 'kiro';
24
+ const role = isKiro ? 'assistant' : 'user';
25
+
26
+ const body = msg.querySelector('.kiro-chat-message-body');
27
+ let content = '';
28
+ if (body) {
29
+ const markdown = body.querySelector('.kiro-chat-message-markdown');
30
+ content = (markdown || body).textContent?.trim() || '';
31
+ }
32
+
33
+ if (content) {
34
+ messages.push({ role, content, index: idx });
35
+ }
36
+ });
37
+
38
+ // 상태 감지
39
+ let status = 'idle';
40
+
41
+ // "Working" / "Cancel" 버튼 → generating
42
+ const workingBar = document.querySelector('.kiro-snackbar');
43
+ if (workingBar && workingBar.offsetWidth > 0) {
44
+ const barText = (workingBar.textContent || '').toLowerCase();
45
+ if (barText.includes('working') || barText.includes('cancel')) {
46
+ status = 'generating';
47
+ }
48
+ }
49
+
50
+ // 입력 필드 내용
51
+ const input = document.querySelector('.tiptap.ProseMirror, [contenteditable="true"]');
52
+ const inputContent = input ? input.textContent?.trim() : '';
53
+
54
+ // 세션 탭
55
+ const tab = document.querySelector('.kiro-tabs-item.active, .kiro-tabs-item[aria-selected="true"]');
56
+ const title = tab?.textContent?.trim() || '';
57
+
58
+ return JSON.stringify({
59
+ id: title || 'kiro-default',
60
+ status,
61
+ messages,
62
+ title: title || undefined,
63
+ inputContent: inputContent || undefined,
64
+ });
65
+ } catch (e) {
66
+ return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
67
+ }
68
+ })()
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Generic fallback — set_model
3
+ * ${ MODEL }
4
+ */
5
+ (() => {
6
+ try {
7
+ const want = ${ MODEL } || '';
8
+ const norm = (t) => t.toLowerCase().trim();
9
+
10
+ // Very basic click attempt
11
+ return JSON.stringify({ success: false, error: 'Model selection requires UI interaction not supported by generic script' });
12
+ } catch (e) {
13
+ return JSON.stringify({ success: false, error: e.message });
14
+ }
15
+ })()
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Generic fallback — set_model
3
+ * ${ MODEL }
4
+ */
5
+ (() => {
6
+ try {
7
+ const want = ${ MODEL } || '';
8
+ const norm = (t) => t.toLowerCase().trim();
9
+
10
+ // Very basic click attempt
11
+ return JSON.stringify({ success: false, error: 'Model selection requires UI interaction not supported by generic script' });
12
+ } catch (e) {
13
+ return JSON.stringify({ success: false, error: e.message });
14
+ }
15
+ })()
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Kiro — webview_switch_session (webview iframe 내부에서 실행)
3
+ *
4
+ * 세션 탭 클릭으로 전환.
5
+ * 파라미터: ${ SESSION_ID } (탭 인덱스)
6
+ */
7
+ (() => {
8
+ try {
9
+ const targetId = ${ SESSION_ID };
10
+ const tabs = document.querySelectorAll('.kiro-tabs-item');
11
+ const idx = parseInt(targetId, 10);
12
+
13
+ if (isNaN(idx) || idx < 0 || idx >= tabs.length) {
14
+ return JSON.stringify({ switched: false, error: `Invalid session index: ${targetId}, total: ${tabs.length}` });
15
+ }
16
+
17
+ tabs[idx].click();
18
+ const label = tabs[idx].querySelector('.kiro-tabs-item-label');
19
+ return JSON.stringify({
20
+ switched: true,
21
+ title: (label?.textContent || tabs[idx].textContent || '').trim(),
22
+ });
23
+ } catch (e) {
24
+ return JSON.stringify({ switched: false, error: e.message });
25
+ }
26
+ })()
@@ -45,8 +45,11 @@ module.exports = {
45
45
  inputMethod: 'cdp-type-and-send',
46
46
  inputSelector: '[contenteditable="true"][role="textbox"]',
47
47
 
48
+ // PearAI의 Agent 채팅 UI는 webview iframe 내부 (Roo Code/Cline 기반)
49
+ webviewMatchText: 'chat-text-area',
50
+
48
51
  scripts: {
49
- readChat() { return loadScript('read_chat.js'); },
52
+ webviewReadChat() { return loadScript('webview_read_chat.js'); },
50
53
  sendMessage(text) {
51
54
  const s = loadScript('send_message.js');
52
55
  return s ? s.replace(/\$\{\s*MESSAGE\s*\}/g, JSON.stringify(text)) : null;
@@ -58,5 +61,28 @@ module.exports = {
58
61
  const s = loadScript('resolve_action.js');
59
62
  return s ? s.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText)) : null;
60
63
  },
64
+ webviewResolveAction(params) {
65
+ const action = typeof params === 'string' ? params : params?.action || 'approve';
66
+ const buttonText = params?.button || params?.buttonText
67
+ || (action === 'approve' ? 'Accept' : action === 'reject' ? 'Reject' : action);
68
+ const s = loadScript('webview_resolve_action.js');
69
+ return s ? s.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText)) : null;
70
+ },
71
+ openPanel() { return loadScript('open_panel.js'); },
72
+ focusEditor() { return loadScript('focus_editor.js'); },
73
+ // 세션 관리 (webview)
74
+ webviewNewSession() { return loadScript('webview_new_session.js'); },
75
+ webviewListModels() { return loadScript('webview_list_models.js'); },
76
+ webviewSetModel(params) {
77
+ const model = typeof params === 'string' ? params : params?.model;
78
+ const s = loadScript('webview_set_model.js');
79
+ return s ? s.replace(/\$\{\s*MODEL\s*\}/g, JSON.stringify(model)) : null;
80
+ },
81
+ webviewListModes() { return loadScript('webview_list_modes.js'); },
82
+ webviewSetMode(params) {
83
+ const mode = typeof params === 'string' ? params : params?.mode;
84
+ const s = loadScript('webview_set_mode.js');
85
+ return s ? s.replace(/\$\{\s*MODE\s*\}/g, JSON.stringify(mode)) : null;
86
+ },
61
87
  },
62
88
  };
@@ -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,46 @@
1
+ /**
2
+ * PearAI — open_panel
3
+ *
4
+ * PearAI 채팅 패널 열기.
5
+ * "Toggle PearAI Side Bar (⌘;)" 버튼으로 열기.
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. Toggle 버튼 클릭 시도
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') || '').toLowerCase();
21
+ if (label.includes('toggle pearai') || label.includes('toggle secondary') ||
22
+ label.includes('toggle auxiliary')) {
23
+ if (btn.offsetWidth > 0 || btn.offsetHeight > 0) {
24
+ btn.click();
25
+ return 'opened (toggle)';
26
+ }
27
+ }
28
+ }
29
+
30
+ // 3. Cmd+; 단축키 폴백 (PearAI 기본 단축키)
31
+ document.dispatchEvent(new KeyboardEvent('keydown', {
32
+ key: ';', code: 'Semicolon', keyCode: 186,
33
+ metaKey: true, ctrlKey: false,
34
+ bubbles: true, cancelable: true,
35
+ }));
36
+ document.dispatchEvent(new KeyboardEvent('keyup', {
37
+ key: ';', code: 'Semicolon', keyCode: 186,
38
+ metaKey: true, ctrlKey: false,
39
+ bubbles: true, cancelable: true,
40
+ }));
41
+
42
+ return 'opened (⌘;)';
43
+ } catch (e) {
44
+ return 'error: ' + e.message;
45
+ }
46
+ })()
@@ -0,0 +1,54 @@
1
+ /**
2
+ * PearAI — resolve_action
3
+ *
4
+ * 승인/거부 버튼 찾기 + 좌표 반환.
5
+ * PearAI의 approval 다이얼로그는 메인 DOM에 표시됨.
6
+ *
7
+ * 파라미터: ${ BUTTON_TEXT }
8
+ */
9
+ (() => {
10
+ const want = ${ BUTTON_TEXT };
11
+ const wantNorm = (want || '').replace(/\s+/g, ' ').trim().toLowerCase();
12
+
13
+ function norm(t) { return (t || '').replace(/\s+/g, ' ').trim().toLowerCase(); }
14
+
15
+ function matches(el) {
16
+ const t = norm(el.textContent);
17
+ if (!t || t.length > 80) return false;
18
+ if (t === wantNorm) return true;
19
+ if (t.indexOf(wantNorm) === 0) return true;
20
+ if (wantNorm.indexOf(t) >= 0 && t.length > 2) return true;
21
+ if (/^(run|approve|allow|accept|yes)\b/.test(wantNorm)) {
22
+ if (/^(run|allow|accept|approve)\b/.test(t)) return true;
23
+ }
24
+ if (/^(reject|deny|no|abort)\b/.test(wantNorm)) {
25
+ if (/^(reject|deny)\b/.test(t)) return true;
26
+ }
27
+ return false;
28
+ }
29
+
30
+ const sel = 'button, [role="button"], .monaco-button';
31
+ const allBtns = [...document.querySelectorAll(sel)].filter(b => {
32
+ if (!b.offsetWidth || !b.getBoundingClientRect().height) return false;
33
+ const rect = b.getBoundingClientRect();
34
+ return rect.y > 0 && rect.y < window.innerHeight;
35
+ });
36
+
37
+ let found = null;
38
+ for (let i = allBtns.length - 1; i >= 0; i--) {
39
+ if (matches(allBtns[i])) { found = allBtns[i]; break; }
40
+ }
41
+
42
+ if (found) {
43
+ const rect = found.getBoundingClientRect();
44
+ return JSON.stringify({
45
+ found: true,
46
+ text: found.textContent?.trim()?.substring(0, 40),
47
+ x: Math.round(rect.x + rect.width / 2),
48
+ y: Math.round(rect.y + rect.height / 2),
49
+ w: Math.round(rect.width),
50
+ h: Math.round(rect.height)
51
+ });
52
+ }
53
+ return JSON.stringify({ found: false, want: wantNorm });
54
+ })()
@@ -0,0 +1,29 @@
1
+ /**
2
+ * PearAI — send_message
3
+ *
4
+ * PearAI의 채팅 입력은 webview iframe 안에 있어 메인 DOM에서 직접 접근 불가.
5
+ * auxbar 하단의 입력 필드 좌표를 계산하여 clickCoords로 반환.
6
+ * 데몬이 CDP Input API로 해당 좌표에 클릭+타이핑+Enter를 수행.
7
+ *
8
+ * 파라미터: ${ MESSAGE }
9
+ */
10
+ (() => {
11
+ try {
12
+ const auxbar = document.getElementById('workbench.parts.auxiliarybar');
13
+ if (!auxbar || auxbar.offsetWidth === 0) {
14
+ return JSON.stringify({ sent: false, error: 'auxbar not found' });
15
+ }
16
+
17
+ const rect = auxbar.getBoundingClientRect();
18
+ const x = Math.round(rect.x + rect.width / 2);
19
+ const y = Math.round(rect.y + rect.height - 80);
20
+
21
+ return JSON.stringify({
22
+ sent: false,
23
+ needsTypeAndSend: true,
24
+ clickCoords: { x, y },
25
+ });
26
+ } catch (e) {
27
+ return JSON.stringify({ sent: false, error: e.message });
28
+ }
29
+ })()
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Cline — list_models
3
+ * 드롭다운에서 사용 가능한 모델 목록 + 현재 선택된 모델 반환
4
+ * → { models: 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({ models: [], current: '', error: 'no doc' });
11
+
12
+ // 현재 모델: mode-switch 또는 model selector에서 읽기
13
+ let current = '';
14
+ const modeSwitch = doc.querySelector('[data-testid="mode-switch"]');
15
+ if (modeSwitch) current = (modeSwitch.textContent || '').trim();
16
+ if (!current) {
17
+ const modelSel = doc.querySelector('[data-testid*="model"], [aria-label*="model" i]');
18
+ if (modelSel) current = (modelSel.textContent || '').trim();
19
+ }
20
+
21
+ // 드롭다운 트리거 찾기
22
+ const trigger = doc.querySelector('[data-testid="model-selector"], [data-testid*="model-dropdown"], [data-testid="dropdown-trigger"]');
23
+ if (!trigger) return JSON.stringify({ models: [], current, error: 'no model trigger' });
24
+
25
+ // 드롭다운 열기
26
+ trigger.click();
27
+ await new Promise(r => setTimeout(r, 300));
28
+
29
+ // 옵션 수집
30
+ const options = doc.querySelectorAll('[data-testid*="dropdown-option"], [role="option"], [class*="dropdown"] [class*="item"], [class*="listbox"] [class*="option"]');
31
+ const models = [];
32
+ for (const opt of options) {
33
+ const text = (opt.textContent || '').trim();
34
+ if (text && text.length > 1 && text.length < 100) models.push(text);
35
+ }
36
+
37
+ // 닫기
38
+ doc.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
39
+ if (trigger.click) trigger.click(); // fallback close
40
+
41
+ return JSON.stringify({ models: [...new Set(models)], current });
42
+ } catch (e) { return JSON.stringify({ models: [], current: '', error: e.message }); }
43
+ })()