adhdev 0.1.51 → 0.1.54

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 (107) hide show
  1. package/dist/index.js +2248 -847
  2. package/package.json +1 -1
  3. package/providers/_builtin/CONTRIBUTING.md +141 -0
  4. package/providers/_builtin/README.md +51 -0
  5. package/providers/_builtin/_helpers/index.js +188 -0
  6. package/providers/_builtin/acp/agentpool/provider.js +59 -0
  7. package/providers/_builtin/acp/amp/provider.js +61 -0
  8. package/providers/_builtin/acp/auggie/provider.js +60 -0
  9. package/providers/_builtin/acp/autodev/provider.js +59 -0
  10. package/providers/_builtin/acp/autohand/provider.js +59 -0
  11. package/providers/_builtin/acp/blackbox-ai/provider.js +59 -0
  12. package/providers/_builtin/acp/claude-agent/provider.js +61 -0
  13. package/providers/_builtin/acp/cline-acp/provider.js +62 -0
  14. package/providers/_builtin/acp/code-assistant/provider.js +59 -0
  15. package/providers/_builtin/acp/codebuddy/provider.js +59 -0
  16. package/providers/_builtin/acp/codex-cli/provider.js +11 -1
  17. package/providers/_builtin/acp/corust-agent/provider.js +59 -0
  18. package/providers/_builtin/acp/crow-cli/provider.js +59 -0
  19. package/providers/_builtin/acp/cursor-acp/provider.js +59 -0
  20. package/providers/_builtin/acp/deepagents/provider.js +59 -0
  21. package/providers/_builtin/acp/dimcode/provider.js +58 -0
  22. package/providers/_builtin/acp/docker-cagent/provider.js +59 -0
  23. package/providers/_builtin/acp/factory-droid/provider.js +59 -0
  24. package/providers/_builtin/acp/fast-agent/provider.js +59 -0
  25. package/providers/_builtin/acp/fount/provider.js +59 -0
  26. package/providers/_builtin/acp/gemini-cli/provider.js +104 -0
  27. package/providers/_builtin/acp/github-copilot/provider.js +60 -0
  28. package/providers/_builtin/acp/goose/provider.js +37 -5
  29. package/providers/_builtin/acp/junie/provider.js +62 -0
  30. package/providers/_builtin/acp/kilo/provider.js +59 -0
  31. package/providers/_builtin/acp/kimi-cli/provider.js +63 -0
  32. package/providers/_builtin/acp/kiro-cli/provider.js +59 -0
  33. package/providers/_builtin/acp/minion-code/provider.js +59 -0
  34. package/providers/_builtin/acp/mistral-vibe/provider.js +63 -0
  35. package/providers/_builtin/acp/nova/provider.js +59 -0
  36. package/providers/_builtin/acp/openclaw/provider.js +59 -0
  37. package/providers/_builtin/acp/opencode/provider.js +34 -6
  38. package/providers/_builtin/acp/openhands/provider.js +59 -0
  39. package/providers/_builtin/acp/pi-acp/provider.js +59 -0
  40. package/providers/_builtin/acp/qoder/provider.js +58 -0
  41. package/providers/_builtin/acp/qwen-code/provider.js +61 -0
  42. package/providers/_builtin/acp/stakpak/provider.js +59 -0
  43. package/providers/_builtin/acp/vtcode/provider.js +59 -0
  44. package/providers/_builtin/cli/claude-cli/provider.js +3 -0
  45. package/providers/_builtin/cli/codex-cli/provider.js +3 -0
  46. package/providers/_builtin/cli/gemini-cli/provider.js +3 -0
  47. package/providers/_builtin/ide/antigravity/scripts/read_chat.js +22 -0
  48. package/providers/_builtin/ide/kiro/provider.js +29 -1
  49. package/providers/_builtin/ide/kiro/scripts/open_panel.js +47 -0
  50. package/providers/_builtin/ide/kiro/scripts/resolve_action.js +54 -0
  51. package/providers/_builtin/ide/kiro/scripts/send_message.js +29 -0
  52. package/providers/_builtin/ide/kiro/scripts/webview_list_models.js +39 -0
  53. package/providers/_builtin/ide/kiro/scripts/webview_list_modes.js +39 -0
  54. package/providers/_builtin/ide/kiro/scripts/webview_list_sessions.js +21 -0
  55. package/providers/_builtin/ide/kiro/scripts/webview_new_session.js +34 -0
  56. package/providers/_builtin/ide/kiro/scripts/webview_read_chat.js +68 -0
  57. package/providers/_builtin/ide/kiro/scripts/webview_send_message.js +72 -0
  58. package/providers/_builtin/ide/kiro/scripts/webview_set_mode.js +15 -0
  59. package/providers/_builtin/ide/kiro/scripts/webview_set_model.js +15 -0
  60. package/providers/_builtin/ide/kiro/scripts/webview_switch_session.js +26 -0
  61. package/providers/_builtin/ide/pearai/provider.js +39 -1
  62. package/providers/_builtin/ide/pearai/scripts/focus_editor.js +20 -0
  63. package/providers/_builtin/ide/pearai/scripts/list_sessions.js +38 -0
  64. package/providers/_builtin/ide/pearai/scripts/new_session.js +55 -0
  65. package/providers/_builtin/ide/pearai/scripts/open_panel.js +46 -0
  66. package/providers/_builtin/ide/pearai/scripts/resolve_action.js +54 -0
  67. package/providers/_builtin/ide/pearai/scripts/send_message.js +29 -0
  68. package/providers/_builtin/ide/pearai/scripts/webview_list_models.js +43 -0
  69. package/providers/_builtin/ide/pearai/scripts/webview_list_modes.js +35 -0
  70. package/providers/_builtin/ide/pearai/scripts/webview_list_sessions.js +62 -0
  71. package/providers/_builtin/ide/pearai/scripts/webview_new_session.js +49 -0
  72. package/providers/_builtin/ide/pearai/scripts/webview_read_chat.js +92 -0
  73. package/providers/_builtin/ide/pearai/scripts/webview_resolve_action.js +59 -0
  74. package/providers/_builtin/ide/pearai/scripts/webview_send_message.js +72 -0
  75. package/providers/_builtin/ide/pearai/scripts/webview_set_mode.js +36 -0
  76. package/providers/_builtin/ide/pearai/scripts/webview_set_model.js +36 -0
  77. package/providers/_builtin/ide/pearai/scripts/webview_switch_session.js +34 -0
  78. package/providers/_builtin/ide/trae/provider.js +22 -1
  79. package/providers/_builtin/ide/trae/scripts/focus_editor.js +20 -0
  80. package/providers/_builtin/ide/trae/scripts/list_chats.js +24 -0
  81. package/providers/_builtin/ide/trae/scripts/list_models.js +39 -0
  82. package/providers/_builtin/ide/trae/scripts/list_modes.js +39 -0
  83. package/providers/_builtin/ide/trae/scripts/new_session.js +30 -0
  84. package/providers/_builtin/ide/trae/scripts/open_panel.js +44 -0
  85. package/providers/_builtin/ide/trae/scripts/read_chat.js +113 -0
  86. package/providers/_builtin/ide/trae/scripts/resolve_action.js +54 -0
  87. package/providers/_builtin/ide/trae/scripts/send_message.js +69 -0
  88. package/providers/_builtin/ide/trae/scripts/set_mode.js +15 -0
  89. package/providers/_builtin/ide/trae/scripts/set_model.js +15 -0
  90. package/providers/_builtin/ide/trae/scripts/switch_session.js +23 -0
  91. package/providers/_builtin/ide/windsurf/provider.js +12 -0
  92. package/providers/_builtin/ide/windsurf/scripts/list_models.js +39 -0
  93. package/providers/_builtin/ide/windsurf/scripts/list_modes.js +39 -0
  94. package/providers/_builtin/ide/windsurf/scripts/set_mode.js +15 -0
  95. package/providers/_builtin/ide/windsurf/scripts/set_model.js +15 -0
  96. package/providers/_builtin/validate.js +156 -0
  97. package/dist/node_datachannel-LPY6EJH5.node +0 -0
  98. package/providers/_builtin/ide/cursor/provider.js.backup +0 -116
  99. package/providers/_builtin/ide/cursor/provider.js.bak +0 -127
  100. package/providers/_builtin/ide/cursor/scripts_backup/list_chats.js +0 -111
  101. package/providers/_builtin/ide/cursor/scripts_backup/new_session.js +0 -62
  102. package/providers/_builtin/ide/cursor/scripts_backup/open_panel.js +0 -31
  103. package/providers/_builtin/ide/cursor/scripts_backup/read_chat.js +0 -433
  104. package/providers/_builtin/ide/cursor/scripts_backup/resolve_action.js +0 -90
  105. package/providers/_builtin/ide/cursor/scripts_backup/send_message.js +0 -86
  106. package/providers/_builtin/ide/cursor/scripts_backup/switch_session.js +0 -63
  107. /package/providers/_builtin/ide/{cursor/scripts_backup → kiro/scripts}/focus_editor.js +0 -0
@@ -229,6 +229,28 @@
229
229
  }
230
230
  }
231
231
  }
232
+ // C: footer 기반 사용량/quota 다이얼로그 (Dismiss / See Plans / Enable Overages 등)
233
+ // <footer> 요소가 conv 안에 존재하고 2개 이상 버튼이 있으면 사용자 액션이 필요한 카드로 판단
234
+ if (!activeModal) {
235
+ const footers = Array.from(conv.querySelectorAll('footer')).filter(f => f.offsetWidth > 0 && f.offsetHeight > 0);
236
+ for (const footer of footers) {
237
+ const footerBtns = Array.from(footer.querySelectorAll('button, a')).filter(b => b.offsetWidth > 0);
238
+ if (footerBtns.length >= 2) {
239
+ // 카드 컨테이너: footer 상위에서 충분한 높이를 가진 첫 번째 요소
240
+ let card = footer.parentElement;
241
+ for (let up = 0; up < 4 && card; up++) {
242
+ if (card.offsetHeight > 60) break;
243
+ card = card.parentElement;
244
+ }
245
+ const msg = card ? (card.innerText || '').trim().slice(0, 300) : '';
246
+ const btnTexts = footerBtns.map(b => (b.innerText || '').trim()).filter(t => t.length > 0 && t.length < 40);
247
+ if (btnTexts.length >= 2) {
248
+ activeModal = { message: msg, buttons: btnTexts, width: card ? card.offsetWidth : 300, height: card ? card.offsetHeight : 100 };
249
+ break;
250
+ }
251
+ }
252
+ }
253
+ }
232
254
  // 모달이 감지되면 status를 waiting_approval로 변경
233
255
  if (activeModal) status = 'waiting_approval';
234
256
  } catch (e) { activeModal = null; }
@@ -45,8 +45,15 @@ module.exports = {
45
45
  inputMethod: 'cdp-type-and-send',
46
46
  inputSelector: '[contenteditable="true"][role="textbox"]',
47
47
 
48
+ // Kiro의 채팅 UI는 webview iframe 내부 (extensionId=kiro.kiroAgent)
49
+ webviewMatchText: 'kiro',
50
+
48
51
  scripts: {
49
- readChat() { return loadScript('read_chat.js'); },
52
+ webviewReadChat() { return loadScript('webview_read_chat.js'); },
53
+ webviewSendMessage(text) {
54
+ const s = loadScript('webview_send_message.js');
55
+ return s ? s.replace(/\$\{\s*MESSAGE\s*\}/g, JSON.stringify(text)) : null;
56
+ },
50
57
  sendMessage(text) {
51
58
  const s = loadScript('send_message.js');
52
59
  return s ? s.replace(/\$\{\s*MESSAGE\s*\}/g, JSON.stringify(text)) : null;
@@ -58,5 +65,26 @@ module.exports = {
58
65
  const s = loadScript('resolve_action.js');
59
66
  return s ? s.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText)) : null;
60
67
  },
68
+ openPanel() { return loadScript('open_panel.js'); },
69
+ focusEditor() { return loadScript('focus_editor.js'); },
70
+ // 세션 관리 (webview)
71
+ webviewListSessions() { return loadScript('webview_list_sessions.js'); },
72
+ webviewNewSession() { return loadScript('webview_new_session.js'); },
73
+ webviewSwitchSession(sessionId) {
74
+ const s = loadScript('webview_switch_session.js');
75
+ return s ? s.replace(/\$\{\s*SESSION_ID\s*\}/g, JSON.stringify(sessionId)) : null;
76
+ },
77
+ webviewListModels() { return loadScript('webview_list_models.js'); },
78
+ webviewSetModel(params) {
79
+ const model = typeof params === 'string' ? params : params?.model;
80
+ const s = loadScript('webview_set_model.js');
81
+ return s ? s.replace(/\$\{\s*MODEL\s*\}/g, JSON.stringify(model)) : null;
82
+ },
83
+ webviewListModes() { return loadScript('webview_list_modes.js'); },
84
+ webviewSetMode(params) {
85
+ const mode = typeof params === 'string' ? params : params?.mode;
86
+ const s = loadScript('webview_set_mode.js');
87
+ return s ? s.replace(/\$\{\s*MODE\s*\}/g, JSON.stringify(mode)) : null;
88
+ },
61
89
  },
62
90
  };
@@ -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,72 @@
1
+ /**
2
+ * Kiro — webview_send_message (webview iframe 내부에서 실행)
3
+ *
4
+ * Kiro의 채팅 입력은 webview iframe 안의 ProseMirror/tiptap 에디터.
5
+ * execCommand('insertText') + Enter 키 이벤트로 메시지 전송.
6
+ *
7
+ * 파라미터: ${ MESSAGE }
8
+ */
9
+ (async () => {
10
+ try {
11
+ const msg = ${ MESSAGE };
12
+
13
+ // ─── 1. 입력 필드 찾기 ───
14
+ const editor =
15
+ document.querySelector('.tiptap.ProseMirror') ||
16
+ document.querySelector('[contenteditable="true"]') ||
17
+ document.querySelector('textarea');
18
+
19
+ if (!editor) return JSON.stringify({ sent: false, error: 'no input found in webview' });
20
+
21
+ const isTextarea = editor.tagName === 'TEXTAREA';
22
+
23
+ if (isTextarea) {
24
+ editor.focus();
25
+ const nativeSetter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')?.set;
26
+ if (nativeSetter) nativeSetter.call(editor, msg);
27
+ else editor.value = msg;
28
+ editor.dispatchEvent(new Event('input', { bubbles: true }));
29
+ await new Promise(r => setTimeout(r, 300));
30
+
31
+ const enterOpts = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true, cancelable: true, composed: true };
32
+ editor.dispatchEvent(new KeyboardEvent('keydown', enterOpts));
33
+ editor.dispatchEvent(new KeyboardEvent('keypress', enterOpts));
34
+ editor.dispatchEvent(new KeyboardEvent('keyup', enterOpts));
35
+ return JSON.stringify({ sent: true });
36
+ }
37
+
38
+ // ─── 2. contenteditable (ProseMirror / tiptap) ───
39
+ editor.focus();
40
+ await new Promise(r => setTimeout(r, 100));
41
+
42
+ // 전체 선택 + 삭제 + 삽입
43
+ const sel = window.getSelection();
44
+ const range = document.createRange();
45
+ range.selectNodeContents(editor);
46
+ sel.removeAllRanges();
47
+ sel.addRange(range);
48
+ await new Promise(r => setTimeout(r, 50));
49
+
50
+ document.execCommand('delete', false, null);
51
+ await new Promise(r => setTimeout(r, 50));
52
+ document.execCommand('insertText', false, msg);
53
+
54
+ editor.dispatchEvent(new Event('input', { bubbles: true }));
55
+ await new Promise(r => setTimeout(r, 400));
56
+
57
+ // ─── 3. Enter 키 전송 ───
58
+ const enterOpts = {
59
+ key: 'Enter', code: 'Enter',
60
+ keyCode: 13, which: 13,
61
+ bubbles: true, cancelable: true, composed: true,
62
+ };
63
+ editor.dispatchEvent(new KeyboardEvent('keydown', enterOpts));
64
+ await new Promise(r => setTimeout(r, 50));
65
+ editor.dispatchEvent(new KeyboardEvent('keypress', enterOpts));
66
+ editor.dispatchEvent(new KeyboardEvent('keyup', enterOpts));
67
+
68
+ return JSON.stringify({ sent: true });
69
+ } catch (e) {
70
+ return JSON.stringify({ sent: false, error: e.message });
71
+ }
72
+ })()
@@ -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,15 @@ 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'); },
53
+ webviewSendMessage(text) {
54
+ const s = loadScript('webview_send_message.js');
55
+ return s ? s.replace(/\$\{\s*MESSAGE\s*\}/g, JSON.stringify(text)) : null;
56
+ },
50
57
  sendMessage(text) {
51
58
  const s = loadScript('send_message.js');
52
59
  return s ? s.replace(/\$\{\s*MESSAGE\s*\}/g, JSON.stringify(text)) : null;
@@ -58,5 +65,36 @@ module.exports = {
58
65
  const s = loadScript('resolve_action.js');
59
66
  return s ? s.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText)) : null;
60
67
  },
68
+ webviewResolveAction(params) {
69
+ const action = typeof params === 'string' ? params : params?.action || 'approve';
70
+ const buttonText = params?.button || params?.buttonText
71
+ || (action === 'approve' ? 'Accept' : action === 'reject' ? 'Reject' : action);
72
+ const s = loadScript('webview_resolve_action.js');
73
+ return s ? s.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText)) : null;
74
+ },
75
+ openPanel() { return loadScript('open_panel.js'); },
76
+ focusEditor() { return loadScript('focus_editor.js'); },
77
+ // 세션 관리 (IDE 메인 프레임)
78
+ newSession() { return loadScript('new_session.js'); },
79
+ listSessions() { return loadScript('list_sessions.js'); },
80
+ // 세션 관리 (webview)
81
+ webviewNewSession() { return loadScript('webview_new_session.js'); },
82
+ webviewListSessions() { return loadScript('webview_list_sessions.js'); },
83
+ webviewSwitchSession(sessionId) {
84
+ const s = loadScript('webview_switch_session.js');
85
+ return s ? s.replace(/\$\{\s*SESSION_ID\s*\}/g, JSON.stringify(sessionId)) : null;
86
+ },
87
+ webviewListModels() { return loadScript('webview_list_models.js'); },
88
+ webviewSetModel(params) {
89
+ const model = typeof params === 'string' ? params : params?.model;
90
+ const s = loadScript('webview_set_model.js');
91
+ return s ? s.replace(/\$\{\s*MODEL\s*\}/g, JSON.stringify(model)) : null;
92
+ },
93
+ webviewListModes() { return loadScript('webview_list_modes.js'); },
94
+ webviewSetMode(params) {
95
+ const mode = typeof params === 'string' ? params : params?.mode;
96
+ const s = loadScript('webview_set_mode.js');
97
+ return s ? s.replace(/\$\{\s*MODE\s*\}/g, JSON.stringify(mode)) : null;
98
+ },
61
99
  },
62
100
  };
@@ -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,38 @@
1
+ /**
2
+ * PearAI — list_sessions (IDE 메인 프레임에서 실행)
3
+ *
4
+ * 히스토리 패널 토글 버튼을 클릭하여 히스토리 뷰를 오픈합니다.
5
+ * 히스토리 뷰가 열리면 webviewListSessions로 항목을 읽을 수 있습니다.
6
+ */
7
+ (() => {
8
+ try {
9
+ // Panel title bar에서 히스토리 관련 버튼 찾기
10
+ const actionBtns = document.querySelectorAll('.action-item a.action-label, .action-item .action-label');
11
+ for (const btn of actionBtns) {
12
+ const title = (btn.getAttribute('title') || '').toLowerCase();
13
+ const ariaLabel = (btn.getAttribute('aria-label') || '').toLowerCase();
14
+ const cls = btn.className || '';
15
+
16
+ if (title.includes('history') || title.includes('히스토리') ||
17
+ ariaLabel.includes('history') || ariaLabel.includes('히스토리') ||
18
+ cls.includes('codicon-history')) {
19
+ btn.click();
20
+ return JSON.stringify({ toggled: true, method: 'panelAction', title: btn.getAttribute('title') });
21
+ }
22
+ }
23
+
24
+ // Broader search
25
+ const allBtns = document.querySelectorAll('a[title], button[title]');
26
+ for (const btn of allBtns) {
27
+ const title = (btn.getAttribute('title') || '').toLowerCase();
28
+ if (title.includes('history') || title.includes('task history')) {
29
+ btn.click();
30
+ return JSON.stringify({ toggled: true, method: 'titleBtn', title: btn.getAttribute('title') });
31
+ }
32
+ }
33
+
34
+ return JSON.stringify({ toggled: false, error: 'History toggle button not found' });
35
+ } catch (e) {
36
+ return JSON.stringify({ toggled: false, error: e.message });
37
+ }
38
+ })()