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
@@ -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
+ })()
@@ -0,0 +1,34 @@
1
+ /**
2
+ * PearAI — webview_switch_session (webview iframe 내부에서 실행)
3
+ *
4
+ * data-testid="task-item-{UUID}" 항목을 클릭하여 세션 전환.
5
+ * SESSION_ID는 task UUID 형태 (예: "51a08aba-1078-410c-a601-0e859205b12c")
6
+ */
7
+ (() => {
8
+ try {
9
+ const targetId = ${SESSION_ID};
10
+
11
+ // ─── UUID 기반 매칭 ───
12
+ const selector = '[data-testid="task-item-' + targetId + '"]';
13
+ const targetItem = document.querySelector(selector);
14
+ if (targetItem) {
15
+ targetItem.click();
16
+ return JSON.stringify({ switched: true, id: targetId });
17
+ }
18
+
19
+ // ─── 인덱스 기반 fallback (숫자로 전달된 경우) ───
20
+ const index = parseInt(targetId, 10);
21
+ if (!isNaN(index)) {
22
+ const allItems = document.querySelectorAll('[data-testid^="task-item-"]');
23
+ if (allItems[index]) {
24
+ allItems[index].click();
25
+ const taskId = (allItems[index].getAttribute('data-testid') || '').replace('task-item-', '');
26
+ return JSON.stringify({ switched: true, id: taskId, method: 'index' });
27
+ }
28
+ }
29
+
30
+ return JSON.stringify({ switched: false, error: 'Task item not found: ' + targetId });
31
+ } catch (e) {
32
+ return JSON.stringify({ switched: false, error: e.message });
33
+ }
34
+ })()
@@ -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
+ })()
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Trae — resolve_action
3
+ *
4
+ * 승인/거부 버튼 찾기 + 좌표 반환.
5
+ * Trae의 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,69 @@
1
+ /**
2
+ * Trae — send_message
3
+ *
4
+ * Trae는 .chat-input-v2-input-box-editable (contenteditable / Lexical) 사용.
5
+ * Lexical의 내부 state를 올바르게 업데이트하기 위해 Selection API + execCommand 사용.
6
+ *
7
+ * 파라미터: ${ MESSAGE }
8
+ */
9
+ (async () => {
10
+ try {
11
+ const msg = ${ MESSAGE };
12
+
13
+ // ─── 1. 입력 필드 찾기 ───
14
+ const editor =
15
+ document.querySelector('.chat-input-v2-input-box-editable') ||
16
+ document.querySelector('[contenteditable="true"][role="textbox"]') ||
17
+ document.querySelector('[data-lexical-editor="true"]');
18
+
19
+ if (!editor) return JSON.stringify({ sent: false, error: 'no input found' });
20
+
21
+ // ─── 2. 포커스 + 전체 선택 + 삭제 + 삽입 ───
22
+ editor.focus();
23
+ await new Promise(r => setTimeout(r, 100));
24
+
25
+ // Selection API로 전체 선택
26
+ const sel = window.getSelection();
27
+ const range = document.createRange();
28
+ range.selectNodeContents(editor);
29
+ sel.removeAllRanges();
30
+ sel.addRange(range);
31
+ await new Promise(r => setTimeout(r, 50));
32
+
33
+ // 삭제 후 삽입 (Lexical state 동기화)
34
+ document.execCommand('delete', false, null);
35
+ await new Promise(r => setTimeout(r, 50));
36
+ document.execCommand('insertText', false, msg);
37
+
38
+ // Input 이벤트
39
+ editor.dispatchEvent(new Event('input', { bubbles: true }));
40
+ await new Promise(r => setTimeout(r, 500));
41
+
42
+ // ─── 3. send 버튼 클릭 ───
43
+ const sendBtn = document.querySelector('.chat-input-v2-send-button');
44
+ if (sendBtn && !sendBtn.disabled) {
45
+ sendBtn.click();
46
+ return JSON.stringify({ sent: true, method: 'button' });
47
+ }
48
+
49
+ // 버튼이 아직 disabled이면 Enter 키 시도
50
+ const enterOpts = {
51
+ key: 'Enter', code: 'Enter',
52
+ keyCode: 13, which: 13,
53
+ bubbles: true, cancelable: true, composed: true,
54
+ };
55
+ editor.dispatchEvent(new KeyboardEvent('keydown', enterOpts));
56
+ await new Promise(r => setTimeout(r, 50));
57
+ editor.dispatchEvent(new KeyboardEvent('keypress', enterOpts));
58
+ editor.dispatchEvent(new KeyboardEvent('keyup', enterOpts));
59
+
60
+ // 여전히 안 되면 needsTypeAndSend 폴백
61
+ return JSON.stringify({
62
+ sent: false,
63
+ needsTypeAndSend: true,
64
+ selector: '.chat-input-v2-input-box-editable',
65
+ });
66
+ } catch (e) {
67
+ return JSON.stringify({ sent: false, error: e.message });
68
+ }
69
+ })()
@@ -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,23 @@
1
+ /**
2
+ * Trae — switch_session
3
+ *
4
+ * Trae 세션 탭 전환.
5
+ * 파라미터: ${ SESSION_ID }
6
+ */
7
+ (() => {
8
+ try {
9
+ const targetId = ${ SESSION_ID };
10
+ const tabs = document.querySelectorAll('.chat-tab-header, [class*="tab-item"], [class*="TabItem"]');
11
+ const idx = parseInt(targetId, 10);
12
+
13
+ if (isNaN(idx) || idx < 0 || idx >= tabs.length) {
14
+ return JSON.stringify({ switched: false, error: `invalid index: ${targetId}` });
15
+ }
16
+
17
+ tabs[idx].click();
18
+ const title = (tabs[idx].textContent || '').replace('✕', '').trim();
19
+ return JSON.stringify({ switched: true, title });
20
+ } catch (e) {
21
+ return JSON.stringify({ switched: false, error: e.message });
22
+ }
23
+ })()
@@ -59,6 +59,18 @@ module.exports = {
59
59
  return s ? s.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText)) : null;
60
60
  },
61
61
  focusEditor() { return loadScript('focus_editor.js'); },
62
+ listModels() { return loadScript('list_models.js'); },
63
+ setModel(params) {
64
+ const model = typeof params === 'string' ? params : params?.model;
65
+ const s = loadScript('set_model.js');
66
+ return s ? s.replace(/\$\{\s*MODEL\s*\}/g, JSON.stringify(model)) : null;
67
+ },
68
+ listModes() { return loadScript('list_modes.js'); },
69
+ setMode(params) {
70
+ const mode = typeof params === 'string' ? params : params?.mode;
71
+ const s = loadScript('set_mode.js');
72
+ return s ? s.replace(/\$\{\s*MODE\s*\}/g, JSON.stringify(mode)) : null;
73
+ },
62
74
  openPanel() { return loadScript('open_panel.js'); },
63
75
  },
64
76
  };
@@ -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
+ })()