@adhdev/daemon-core 0.5.3

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 (217) hide show
  1. package/dist/index.d.ts +2662 -0
  2. package/dist/index.js +11341 -0
  3. package/dist/index.js.map +1 -0
  4. package/package.json +48 -0
  5. package/providers/_builtin/.github/workflows/generate-registry.yml +57 -0
  6. package/providers/_builtin/COMPATIBILITY.md +217 -0
  7. package/providers/_builtin/CONTRIBUTING.md +200 -0
  8. package/providers/_builtin/README.md +119 -0
  9. package/providers/_builtin/_helpers/index.js +188 -0
  10. package/providers/_builtin/acp/agentpool/provider.json +54 -0
  11. package/providers/_builtin/acp/amp/provider.json +52 -0
  12. package/providers/_builtin/acp/auggie/provider.json +57 -0
  13. package/providers/_builtin/acp/autodev/provider.json +54 -0
  14. package/providers/_builtin/acp/autohand/provider.json +52 -0
  15. package/providers/_builtin/acp/blackbox-ai/provider.json +54 -0
  16. package/providers/_builtin/acp/claude-agent/provider.json +57 -0
  17. package/providers/_builtin/acp/cline-acp/provider.json +54 -0
  18. package/providers/_builtin/acp/codebuddy/provider.json +54 -0
  19. package/providers/_builtin/acp/codex-cli/provider.json +57 -0
  20. package/providers/_builtin/acp/corust-agent/provider.json +52 -0
  21. package/providers/_builtin/acp/crow-cli/provider.json +54 -0
  22. package/providers/_builtin/acp/cursor-acp/provider.json +54 -0
  23. package/providers/_builtin/acp/deepagents/provider.json +52 -0
  24. package/providers/_builtin/acp/dimcode/provider.json +54 -0
  25. package/providers/_builtin/acp/docker-cagent/provider.json +57 -0
  26. package/providers/_builtin/acp/factory-droid/provider.json +60 -0
  27. package/providers/_builtin/acp/fast-agent/provider.json +52 -0
  28. package/providers/_builtin/acp/gemini-cli/provider.json +114 -0
  29. package/providers/_builtin/acp/github-copilot/provider.json +54 -0
  30. package/providers/_builtin/acp/goose/provider.json +57 -0
  31. package/providers/_builtin/acp/junie/provider.json +52 -0
  32. package/providers/_builtin/acp/kilo/provider.json +54 -0
  33. package/providers/_builtin/acp/kimi-cli/provider.json +57 -0
  34. package/providers/_builtin/acp/minion-code/provider.json +52 -0
  35. package/providers/_builtin/acp/mistral-vibe/provider.json +57 -0
  36. package/providers/_builtin/acp/nova/provider.json +54 -0
  37. package/providers/_builtin/acp/openclaw/provider.json +54 -0
  38. package/providers/_builtin/acp/opencode/provider.json +52 -0
  39. package/providers/_builtin/acp/openhands/provider.json +54 -0
  40. package/providers/_builtin/acp/pi-acp/provider.json +52 -0
  41. package/providers/_builtin/acp/qoder/provider.json +54 -0
  42. package/providers/_builtin/acp/qwen-code/provider.json +60 -0
  43. package/providers/_builtin/acp/stakpak/provider.json +54 -0
  44. package/providers/_builtin/acp/vtcode/provider.json +54 -0
  45. package/providers/_builtin/cli/claude-cli/provider.json +100 -0
  46. package/providers/_builtin/cli/codex-cli/provider.json +89 -0
  47. package/providers/_builtin/cli/gemini-cli/provider.json +93 -0
  48. package/providers/_builtin/docs/CDP_SELECTOR_GUIDE.md +370 -0
  49. package/providers/_builtin/docs/PROVIDER_GUIDE.md +916 -0
  50. package/providers/_builtin/extension/cline/provider.json +35 -0
  51. package/providers/_builtin/extension/cline/scripts/focus_editor.js +48 -0
  52. package/providers/_builtin/extension/cline/scripts/list_chats.js +100 -0
  53. package/providers/_builtin/extension/cline/scripts/list_models.js +43 -0
  54. package/providers/_builtin/extension/cline/scripts/list_modes.js +35 -0
  55. package/providers/_builtin/extension/cline/scripts/new_session.js +85 -0
  56. package/providers/_builtin/extension/cline/scripts/open_panel.js +25 -0
  57. package/providers/_builtin/extension/cline/scripts/read_chat.js +257 -0
  58. package/providers/_builtin/extension/cline/scripts/resolve_action.js +83 -0
  59. package/providers/_builtin/extension/cline/scripts/send_message.js +95 -0
  60. package/providers/_builtin/extension/cline/scripts/set_mode.js +36 -0
  61. package/providers/_builtin/extension/cline/scripts/set_model.js +36 -0
  62. package/providers/_builtin/extension/cline/scripts/switch_session.js +206 -0
  63. package/providers/_builtin/extension/cline/scripts.js +73 -0
  64. package/providers/_builtin/extension/roo-code/provider.json +35 -0
  65. package/providers/_builtin/extension/roo-code/scripts.js +659 -0
  66. package/providers/_builtin/ide/antigravity/provider.json +68 -0
  67. package/providers/_builtin/ide/antigravity/scripts/1.106/focus_editor.js +20 -0
  68. package/providers/_builtin/ide/antigravity/scripts/1.106/list_chats.js +137 -0
  69. package/providers/_builtin/ide/antigravity/scripts/1.106/list_models.js +38 -0
  70. package/providers/_builtin/ide/antigravity/scripts/1.106/list_modes.js +48 -0
  71. package/providers/_builtin/ide/antigravity/scripts/1.106/new_session.js +75 -0
  72. package/providers/_builtin/ide/antigravity/scripts/1.106/read_chat.js +262 -0
  73. package/providers/_builtin/ide/antigravity/scripts/1.106/resolve_action.js +68 -0
  74. package/providers/_builtin/ide/antigravity/scripts/1.106/scripts.js +57 -0
  75. package/providers/_builtin/ide/antigravity/scripts/1.106/send_message.js +56 -0
  76. package/providers/_builtin/ide/antigravity/scripts/1.106/set_mode.js +34 -0
  77. package/providers/_builtin/ide/antigravity/scripts/1.106/set_model.js +47 -0
  78. package/providers/_builtin/ide/antigravity/scripts/1.106/switch_session.js +114 -0
  79. package/providers/_builtin/ide/antigravity/scripts/1.107/focus_editor.js +20 -0
  80. package/providers/_builtin/ide/antigravity/scripts/1.107/list_chats.js +137 -0
  81. package/providers/_builtin/ide/antigravity/scripts/1.107/list_models.js +61 -0
  82. package/providers/_builtin/ide/antigravity/scripts/1.107/list_modes.js +72 -0
  83. package/providers/_builtin/ide/antigravity/scripts/1.107/new_session.js +75 -0
  84. package/providers/_builtin/ide/antigravity/scripts/1.107/read_chat.js +262 -0
  85. package/providers/_builtin/ide/antigravity/scripts/1.107/resolve_action.js +68 -0
  86. package/providers/_builtin/ide/antigravity/scripts/1.107/scripts.js +67 -0
  87. package/providers/_builtin/ide/antigravity/scripts/1.107/send_message.js +56 -0
  88. package/providers/_builtin/ide/antigravity/scripts/1.107/set_mode.js +67 -0
  89. package/providers/_builtin/ide/antigravity/scripts/1.107/set_model.js +72 -0
  90. package/providers/_builtin/ide/antigravity/scripts/1.107/switch_session.js +114 -0
  91. package/providers/_builtin/ide/cursor/provider.json +70 -0
  92. package/providers/_builtin/ide/cursor/scripts/0.49/dismiss_notification.js +30 -0
  93. package/providers/_builtin/ide/cursor/scripts/0.49/focus_editor.js +13 -0
  94. package/providers/_builtin/ide/cursor/scripts/0.49/list_models.js +78 -0
  95. package/providers/_builtin/ide/cursor/scripts/0.49/list_modes.js +40 -0
  96. package/providers/_builtin/ide/cursor/scripts/0.49/list_notifications.js +23 -0
  97. package/providers/_builtin/ide/cursor/scripts/0.49/list_sessions.js +42 -0
  98. package/providers/_builtin/ide/cursor/scripts/0.49/new_session.js +20 -0
  99. package/providers/_builtin/ide/cursor/scripts/0.49/open_panel.js +23 -0
  100. package/providers/_builtin/ide/cursor/scripts/0.49/read_chat.js +75 -0
  101. package/providers/_builtin/ide/cursor/scripts/0.49/resolve_action.js +19 -0
  102. package/providers/_builtin/ide/cursor/scripts/0.49/scripts.js +78 -0
  103. package/providers/_builtin/ide/cursor/scripts/0.49/send_message.js +23 -0
  104. package/providers/_builtin/ide/cursor/scripts/0.49/set_mode.js +38 -0
  105. package/providers/_builtin/ide/cursor/scripts/0.49/set_model.js +81 -0
  106. package/providers/_builtin/ide/cursor/scripts/0.49/switch_session.js +28 -0
  107. package/providers/_builtin/ide/kiro/provider.json +67 -0
  108. package/providers/_builtin/ide/kiro/scripts/focus_editor.js +20 -0
  109. package/providers/_builtin/ide/kiro/scripts/open_panel.js +47 -0
  110. package/providers/_builtin/ide/kiro/scripts/resolve_action.js +54 -0
  111. package/providers/_builtin/ide/kiro/scripts/send_message.js +29 -0
  112. package/providers/_builtin/ide/kiro/scripts/webview_list_models.js +39 -0
  113. package/providers/_builtin/ide/kiro/scripts/webview_list_modes.js +39 -0
  114. package/providers/_builtin/ide/kiro/scripts/webview_list_sessions.js +21 -0
  115. package/providers/_builtin/ide/kiro/scripts/webview_new_session.js +34 -0
  116. package/providers/_builtin/ide/kiro/scripts/webview_read_chat.js +68 -0
  117. package/providers/_builtin/ide/kiro/scripts/webview_send_message.js +72 -0
  118. package/providers/_builtin/ide/kiro/scripts/webview_set_mode.js +15 -0
  119. package/providers/_builtin/ide/kiro/scripts/webview_set_model.js +15 -0
  120. package/providers/_builtin/ide/kiro/scripts/webview_switch_session.js +26 -0
  121. package/providers/_builtin/ide/kiro/scripts.js +62 -0
  122. package/providers/_builtin/ide/pearai/provider.json +67 -0
  123. package/providers/_builtin/ide/pearai/scripts/focus_editor.js +20 -0
  124. package/providers/_builtin/ide/pearai/scripts/list_sessions.js +38 -0
  125. package/providers/_builtin/ide/pearai/scripts/new_session.js +55 -0
  126. package/providers/_builtin/ide/pearai/scripts/open_panel.js +46 -0
  127. package/providers/_builtin/ide/pearai/scripts/resolve_action.js +54 -0
  128. package/providers/_builtin/ide/pearai/scripts/send_message.js +29 -0
  129. package/providers/_builtin/ide/pearai/scripts/webview_list_models.js +43 -0
  130. package/providers/_builtin/ide/pearai/scripts/webview_list_modes.js +35 -0
  131. package/providers/_builtin/ide/pearai/scripts/webview_list_sessions.js +62 -0
  132. package/providers/_builtin/ide/pearai/scripts/webview_new_session.js +49 -0
  133. package/providers/_builtin/ide/pearai/scripts/webview_read_chat.js +92 -0
  134. package/providers/_builtin/ide/pearai/scripts/webview_resolve_action.js +59 -0
  135. package/providers/_builtin/ide/pearai/scripts/webview_send_message.js +72 -0
  136. package/providers/_builtin/ide/pearai/scripts/webview_set_mode.js +36 -0
  137. package/providers/_builtin/ide/pearai/scripts/webview_set_model.js +36 -0
  138. package/providers/_builtin/ide/pearai/scripts/webview_switch_session.js +34 -0
  139. package/providers/_builtin/ide/pearai/scripts.js +74 -0
  140. package/providers/_builtin/ide/trae/provider.json +66 -0
  141. package/providers/_builtin/ide/trae/scripts/focus_editor.js +20 -0
  142. package/providers/_builtin/ide/trae/scripts/list_chats.js +24 -0
  143. package/providers/_builtin/ide/trae/scripts/list_models.js +39 -0
  144. package/providers/_builtin/ide/trae/scripts/list_modes.js +39 -0
  145. package/providers/_builtin/ide/trae/scripts/new_session.js +30 -0
  146. package/providers/_builtin/ide/trae/scripts/open_panel.js +44 -0
  147. package/providers/_builtin/ide/trae/scripts/read_chat.js +113 -0
  148. package/providers/_builtin/ide/trae/scripts/resolve_action.js +54 -0
  149. package/providers/_builtin/ide/trae/scripts/send_message.js +69 -0
  150. package/providers/_builtin/ide/trae/scripts/set_mode.js +15 -0
  151. package/providers/_builtin/ide/trae/scripts/set_model.js +15 -0
  152. package/providers/_builtin/ide/trae/scripts/switch_session.js +23 -0
  153. package/providers/_builtin/ide/trae/scripts.js +57 -0
  154. package/providers/_builtin/ide/vscode/provider.json +64 -0
  155. package/providers/_builtin/ide/vscode-insiders/provider.json +62 -0
  156. package/providers/_builtin/ide/vscodium/provider.json +63 -0
  157. package/providers/_builtin/ide/windsurf/provider.json +53 -0
  158. package/providers/_builtin/ide/windsurf/scripts/focus_editor.js +30 -0
  159. package/providers/_builtin/ide/windsurf/scripts/list_chats.js +117 -0
  160. package/providers/_builtin/ide/windsurf/scripts/list_models.js +39 -0
  161. package/providers/_builtin/ide/windsurf/scripts/list_modes.js +39 -0
  162. package/providers/_builtin/ide/windsurf/scripts/new_session.js +69 -0
  163. package/providers/_builtin/ide/windsurf/scripts/open_panel.js +58 -0
  164. package/providers/_builtin/ide/windsurf/scripts/read_chat.js +297 -0
  165. package/providers/_builtin/ide/windsurf/scripts/resolve_action.js +68 -0
  166. package/providers/_builtin/ide/windsurf/scripts/send_message.js +87 -0
  167. package/providers/_builtin/ide/windsurf/scripts/set_mode.js +15 -0
  168. package/providers/_builtin/ide/windsurf/scripts/set_model.js +15 -0
  169. package/providers/_builtin/ide/windsurf/scripts/switch_session.js +58 -0
  170. package/providers/_builtin/ide/windsurf/scripts.js +57 -0
  171. package/providers/_builtin/registry.json +266 -0
  172. package/providers/_builtin/validate.js +156 -0
  173. package/src/agent-stream/index.ts +6 -0
  174. package/src/agent-stream/manager.ts +286 -0
  175. package/src/agent-stream/poller.ts +154 -0
  176. package/src/agent-stream/provider-adapter.ts +138 -0
  177. package/src/agent-stream/types.ts +61 -0
  178. package/src/boot/daemon-lifecycle.ts +252 -0
  179. package/src/cdp/devtools.ts +335 -0
  180. package/src/cdp/initializer.ts +191 -0
  181. package/src/cdp/manager.ts +897 -0
  182. package/src/cdp/scanner.ts +185 -0
  183. package/src/cdp/setup.ts +150 -0
  184. package/src/cli-adapter-types.ts +25 -0
  185. package/src/cli-adapters/provider-cli-adapter.ts +448 -0
  186. package/src/commands/cdp-commands.ts +208 -0
  187. package/src/commands/chat-commands.ts +675 -0
  188. package/src/commands/cli-manager.ts +353 -0
  189. package/src/commands/handler.ts +328 -0
  190. package/src/commands/router.ts +258 -0
  191. package/src/commands/stream-commands.ts +325 -0
  192. package/src/config/chat-history.ts +211 -0
  193. package/src/config/config.ts +219 -0
  194. package/src/daemon/dev-server.ts +2378 -0
  195. package/src/daemon/scaffold-template.ts +394 -0
  196. package/src/daemon-core.ts +50 -0
  197. package/src/detection/cli-detector.ts +89 -0
  198. package/src/detection/ide-detector.ts +157 -0
  199. package/src/index.ts +103 -0
  200. package/src/installer.ts +263 -0
  201. package/src/ipc-protocol.ts +133 -0
  202. package/src/launch.ts +433 -0
  203. package/src/logging/command-log.ts +180 -0
  204. package/src/logging/logger.ts +316 -0
  205. package/src/providers/acp-provider-instance.ts +1140 -0
  206. package/src/providers/cli-provider-instance.ts +207 -0
  207. package/src/providers/contracts.ts +524 -0
  208. package/src/providers/extension-provider-instance.ts +156 -0
  209. package/src/providers/ide-provider-instance.ts +377 -0
  210. package/src/providers/index.ts +18 -0
  211. package/src/providers/provider-instance-manager.ts +182 -0
  212. package/src/providers/provider-instance.ts +112 -0
  213. package/src/providers/provider-loader.ts +1031 -0
  214. package/src/providers/status-monitor.ts +125 -0
  215. package/src/providers/version-archive.ts +266 -0
  216. package/src/status/reporter.ts +294 -0
  217. package/src/types.ts +206 -0
@@ -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
+ })()
@@ -0,0 +1,62 @@
1
+ /**
2
+ * CDP Scripts for Kiro
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const SCRIPTS_DIR = path.join(__dirname, 'scripts');
8
+ function loadScript(name) {
9
+ try { return fs.readFileSync(path.join(SCRIPTS_DIR, name), 'utf8'); }
10
+ catch { return null; }
11
+ }
12
+
13
+
14
+ module.exports.webviewReadChat = function webviewReadChat() { return loadScript('webview_read_chat.js'); };
15
+
16
+ module.exports.webviewSendMessage = function webviewSendMessage(text) {
17
+ const s = loadScript('webview_send_message.js');
18
+ return s ? s.replace(/\$\{\s*MESSAGE\s*\}/g, JSON.stringify(text)) : null;
19
+ };
20
+
21
+ module.exports.sendMessage = function sendMessage(text) {
22
+ const s = loadScript('send_message.js');
23
+ return s ? s.replace(/\$\{\s*MESSAGE\s*\}/g, JSON.stringify(text)) : null;
24
+ };
25
+
26
+ module.exports.resolveAction = function resolveAction(params) {
27
+ const action = typeof params === 'string' ? params : params?.action || 'approve';
28
+ const buttonText = params?.button || params?.buttonText
29
+ || (action === 'approve' ? 'Accept' : action === 'reject' ? 'Reject' : action);
30
+ const s = loadScript('resolve_action.js');
31
+ return s ? s.replace(/\$\{\s*BUTTON_TEXT\s*\}/g, JSON.stringify(buttonText)) : null;
32
+ };
33
+
34
+ module.exports.openPanel = function openPanel() { return loadScript('open_panel.js'); };
35
+
36
+ module.exports.focusEditor = function focusEditor() { return loadScript('focus_editor.js'); };
37
+
38
+ module.exports.webviewListSessions = function webviewListSessions() { return loadScript('webview_list_sessions.js'); };
39
+
40
+ module.exports.webviewNewSession = function webviewNewSession() { return loadScript('webview_new_session.js'); };
41
+
42
+ module.exports.webviewSwitchSession = function webviewSwitchSession(sessionId) {
43
+ const s = loadScript('webview_switch_session.js');
44
+ return s ? s.replace(/\$\{\s*SESSION_ID\s*\}/g, JSON.stringify(sessionId)) : null;
45
+ };
46
+
47
+ module.exports.webviewListModels = function webviewListModels() { return loadScript('webview_list_models.js'); };
48
+
49
+ module.exports.webviewSetModel = function webviewSetModel(params) {
50
+ const model = typeof params === 'string' ? params : params?.model;
51
+ const s = loadScript('webview_set_model.js');
52
+ return s ? s.replace(/\$\{\s*MODEL\s*\}/g, JSON.stringify(model)) : null;
53
+ };
54
+
55
+ module.exports.webviewListModes = function webviewListModes() { return loadScript('webview_list_modes.js'); };
56
+
57
+ module.exports.webviewSetMode = function webviewSetMode(params) {
58
+ const mode = typeof params === 'string' ? params : params?.mode;
59
+ const s = loadScript('webview_set_mode.js');
60
+ return s ? s.replace(/\$\{\s*MODE\s*\}/g, JSON.stringify(mode)) : null;
61
+ };
62
+
@@ -0,0 +1,67 @@
1
+ {
2
+ "type": "pearai",
3
+ "name": "PearAI",
4
+ "category": "ide",
5
+ "displayName": "PearAI",
6
+ "icon": "🍐",
7
+ "cli": "pearai",
8
+ "cdpPorts": [
9
+ 9355,
10
+ 9356
11
+ ],
12
+ "targetFilter": {
13
+ "urlIncludes": "workbench.html",
14
+ "urlExcludes": [
15
+ "agent"
16
+ ],
17
+ "titleExcludes": "extension-output|ADHDev CDP|Debug Console|Output\\s*$|Launchpad"
18
+ },
19
+ "processNames": {
20
+ "darwin": "PearAI",
21
+ "win32": [
22
+ "PearAI.exe"
23
+ ],
24
+ "linux": [
25
+ "pearai"
26
+ ]
27
+ },
28
+ "paths": {
29
+ "darwin": [
30
+ "/Applications/PearAI.app"
31
+ ],
32
+ "win32": [
33
+ "C:\\Users\\*\\AppData\\Local\\Programs\\pearai\\PearAI.exe"
34
+ ],
35
+ "linux": [
36
+ "/opt/pearai",
37
+ "/usr/share/pearai"
38
+ ]
39
+ },
40
+ "inputMethod": "cdp-type-and-send",
41
+ "inputSelector": "[contenteditable=\"true\"][role=\"textbox\"]",
42
+ "webviewMatchText": "chat-text-area",
43
+ "settings": {
44
+ "approvalAlert": {
45
+ "type": "boolean",
46
+ "default": true,
47
+ "public": true,
48
+ "label": "Approval Notifications",
49
+ "description": "Show notification when approval is needed"
50
+ },
51
+ "longGeneratingAlert": {
52
+ "type": "boolean",
53
+ "default": true,
54
+ "public": true,
55
+ "label": "Long Generation Alert",
56
+ "description": "Alert when generation takes too long"
57
+ },
58
+ "longGeneratingThresholdSec": {
59
+ "type": "number",
60
+ "default": 180,
61
+ "public": true,
62
+ "label": "Long Generation Threshold (sec)",
63
+ "min": 30,
64
+ "max": 600
65
+ }
66
+ }
67
+ }
@@ -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
+ })()
@@ -0,0 +1,55 @@
1
+ /**
2
+ * PearAI — new_session (IDE 메인 프레임에서 실행)
3
+ *
4
+ * Panel title bar의 "+" 버튼(New Task)을 찾아 클릭합니다.
5
+ * PearAI(Roo Code 기반)에서 새 태스크 버튼은 webview 바깥의 VS Code panel 헤더에 위치합니다.
6
+ */
7
+ (() => {
8
+ try {
9
+ // Strategy 1: Find the codicon-add / plus button in panel title actions
10
+ const actionBtns = document.querySelectorAll('.panel .title .actions-container .action-item a, .pane-header .actions-container .action-item a, .title-actions .action-item a');
11
+ for (const btn of actionBtns) {
12
+ const title = btn.getAttribute('title') || '';
13
+ const ariaLabel = btn.getAttribute('aria-label') || '';
14
+ const cls = btn.className || '';
15
+
16
+ if (title.toLowerCase().includes('new task') ||
17
+ title.toLowerCase().includes('new chat') ||
18
+ ariaLabel.toLowerCase().includes('new task') ||
19
+ ariaLabel.toLowerCase().includes('new chat') ||
20
+ cls.includes('codicon-add') ||
21
+ cls.includes('codicon-plus')) {
22
+ btn.click();
23
+ return JSON.stringify({ created: true, method: 'panelAction', title: title || ariaLabel });
24
+ }
25
+ }
26
+
27
+ // Strategy 2: Broader search for action items with "+" or "new"
28
+ const allActions = document.querySelectorAll('.action-item a.action-label');
29
+ for (const a of allActions) {
30
+ const title = (a.getAttribute('title') || '').toLowerCase();
31
+ const cls = a.className || '';
32
+ if ((title.includes('new') && title.includes('task')) ||
33
+ (title.includes('plus') || cls.includes('codicon-add'))) {
34
+ a.click();
35
+ return JSON.stringify({ created: true, method: 'actionLabel', title: a.getAttribute('title') });
36
+ }
37
+ }
38
+
39
+ // Strategy 3: Use keybinding (Cmd+Shift+P -> "new task")
40
+ // Simulate keyboard shortcut for Roo Code: typically there's a command
41
+ // registered as roo-cline.plusButtonClicked or similar
42
+ const allBtns = document.querySelectorAll('a[title], button[title]');
43
+ const matches = [];
44
+ for (const btn of allBtns) {
45
+ const t = btn.getAttribute('title') || '';
46
+ if (t.toLowerCase().includes('new') || t.toLowerCase().includes('plus') || t === '+') {
47
+ matches.push({ tag: btn.tagName, title: t, cls: (btn.className || '').substring(0, 60) });
48
+ }
49
+ }
50
+
51
+ return JSON.stringify({ created: false, error: 'New Task button not found in panel', candidates: matches.slice(0, 5) });
52
+ } catch (e) {
53
+ return JSON.stringify({ created: false, error: e.message });
54
+ }
55
+ })()
@@ -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
+ })()
@@ -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,62 @@
1
+ /**
2
+ * PearAI — webview_list_sessions (webview iframe 내부에서 실행)
3
+ *
4
+ * PearAI(Roo Code/Cline 기반) 히스토리 뷰에서 세션 목록을 추출.
5
+ * 각 항목은 data-testid="task-item-{UUID}" 로 식별됨.
6
+ */
7
+ (() => {
8
+ try {
9
+ // ─── 히스토리 항목: data-testid="task-item-*" ───
10
+ const taskItems = document.querySelectorAll('[data-testid^="task-item-"]');
11
+
12
+ if (taskItems.length > 0) {
13
+ const sessions = [];
14
+ for (let i = 0; i < taskItems.length; i++) {
15
+ const item = taskItems[i];
16
+ if (!item) continue;
17
+
18
+ const testId = item.getAttribute('data-testid') || '';
19
+ const taskId = testId.replace('task-item-', '');
20
+
21
+ // 전체 텍스트에서 제목 추출
22
+ const fullText = (item.textContent || '').trim();
23
+
24
+ // 구조: "MARCH 16, 1:31 AM 173 B test123 Tokens:10.4k 229"
25
+ // 전략: Tokens: 앞의 마지막 의미있는 텍스트를 제목으로 사용
26
+ let title = '';
27
+ let date = '';
28
+
29
+ // 날짜 추출
30
+ const dateMatch = fullText.match(/^([A-Z]+\s+\d+,\s*\d+:\d+\s*[AP]M)/);
31
+ if (dateMatch) date = dateMatch[1];
32
+
33
+ // 제목 추출: 날짜와 크기(B/kB) 뒤, Tokens: 앞
34
+ const titleMatch = fullText.match(/[AP]M[\d.\s]*[kMG]?B\s*(.*?)(?:Tokens:|$)/s);
35
+ if (titleMatch && titleMatch[1]) {
36
+ title = titleMatch[1].trim();
37
+ }
38
+
39
+ // fallback: 첫 80자
40
+ if (!title) {
41
+ title = fullText.substring(0, 80);
42
+ }
43
+
44
+ sessions.push({
45
+ id: taskId,
46
+ title: title.substring(0, 100),
47
+ date: date,
48
+ active: false
49
+ });
50
+ }
51
+ return JSON.stringify({ sessions: sessions });
52
+ }
53
+
54
+ // ─── 히스토리 뷰가 열려 있지 않음 ───
55
+ return JSON.stringify({
56
+ sessions: [],
57
+ note: 'History view not open. Toggle history first.'
58
+ });
59
+ } catch (e) {
60
+ return JSON.stringify({ sessions: [], error: String(e.message || e) });
61
+ }
62
+ })()
@@ -0,0 +1,49 @@
1
+ /**
2
+ * PearAI — webview_new_session (webview iframe 내부에서 실행)
3
+ *
4
+ * Roo Code/Cline 기반 PearAI에서 새 세션(태스크)을 시작합니다.
5
+ * 1) "New Task" 텍스트를 가진 버튼 클릭 시도
6
+ * 2) 실패 시, vscode postMessage API로 newTask 명령 전송 시도
7
+ * 3) 실패 시, chat-text-area를 초기화하여 새 세션 상태로 진입
8
+ */
9
+ (() => {
10
+ try {
11
+ // Strategy 1: Find "New Task" button text
12
+ const buttons = document.querySelectorAll('button, [role="button"]');
13
+ for (const btn of buttons) {
14
+ const text = (btn.textContent || '').trim();
15
+ if (text.includes('Start New Task') || text.includes('New Task') || text.includes('New Chat')) {
16
+ btn.click();
17
+ return JSON.stringify({ created: true, method: 'button', text });
18
+ }
19
+ }
20
+
21
+ // Strategy 2: Look for a "+" (plus/add) button that might create new tasks
22
+ for (const btn of buttons) {
23
+ const title = btn.getAttribute('title') || '';
24
+ const ariaLabel = btn.getAttribute('aria-label') || '';
25
+ if (title.includes('New') || ariaLabel.includes('New') ||
26
+ title.includes('new') || ariaLabel.includes('new')) {
27
+ btn.click();
28
+ return JSON.stringify({ created: true, method: 'title', title: title || ariaLabel });
29
+ }
30
+ }
31
+
32
+ // Strategy 3: Use vscode API to post message for new task
33
+ if (typeof acquireVsCodeApi !== 'undefined') {
34
+ const vscode = acquireVsCodeApi();
35
+ vscode.postMessage({ type: 'newTask' });
36
+ return JSON.stringify({ created: true, method: 'vscodeApi' });
37
+ }
38
+
39
+ // Strategy 4: If already in empty state (no messages), report as already new
40
+ const messages = document.querySelectorAll('[class*="message"], [class*="chat-row"]');
41
+ if (messages.length === 0) {
42
+ return JSON.stringify({ created: true, method: 'alreadyNew', note: 'No messages - already in new session state' });
43
+ }
44
+
45
+ return JSON.stringify({ created: false, error: 'New Task button not found' });
46
+ } catch (e) {
47
+ return JSON.stringify({ created: false, error: e.message });
48
+ }
49
+ })()