@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
package/src/index.ts ADDED
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @adhdev/daemon-core — Public API
3
+ *
4
+ * Core logic for daemon: CDP, Provider, IDE detection, CLI/ACP adapters and more.
5
+ * Used by both daemon-standalone and daemon-cloud.
6
+ */
7
+
8
+ // ── Types ──
9
+ export type {
10
+ DaemonStatus,
11
+ IdeEntry,
12
+ CliEntry,
13
+ AcpEntry,
14
+ ChatMessage,
15
+ ExtensionInfo,
16
+ CommandResult as CoreCommandResult,
17
+ ProviderConfig,
18
+ DaemonEvent,
19
+ StatusResponse,
20
+ SystemInfo,
21
+ DetectedIde,
22
+ ProviderInfo,
23
+ AgentStreamEntry,
24
+ AgentEntry,
25
+ } from './types.js';
26
+
27
+ // ── Core Interface ──
28
+ export type { IDaemonCore, DaemonCoreOptions } from './daemon-core.js';
29
+
30
+ // ── Config ──
31
+ export { loadConfig, saveConfig, resetConfig, isSetupComplete, addCliHistory, markSetupComplete, updateConfig } from './config/config.js';
32
+
33
+ // ── Detection ──
34
+ export { detectIDEs } from './detection/ide-detector.js';
35
+ export type { IDEInfo } from './detection/ide-detector.js';
36
+ export { detectCLIs } from './detection/cli-detector.js';
37
+
38
+ // ── CDP ──
39
+ export { DaemonCdpManager } from './cdp/manager.js';
40
+ export { CdpDomHandlers } from './cdp/devtools.js';
41
+ export { setupIdeInstance, registerExtensionProviders, connectCdpManager, probeCdpPort } from './cdp/setup.js';
42
+ export type { CdpSetupContext, SetupIdeInstanceOptions } from './cdp/setup.js';
43
+ export { DaemonCdpScanner } from './cdp/scanner.js';
44
+ export type { CdpScannerOptions } from './cdp/scanner.js';
45
+ export { DaemonCdpInitializer } from './cdp/initializer.js';
46
+ export type { CdpInitializerConfig } from './cdp/initializer.js';
47
+
48
+ // ── Commands ──
49
+ export { DaemonCommandHandler } from './commands/handler.js';
50
+ export type { CommandResult, CommandContext } from './commands/handler.js';
51
+ export { DaemonCommandRouter } from './commands/router.js';
52
+ export type { CommandRouterDeps, CommandRouterResult } from './commands/router.js';
53
+
54
+ // ── Status ──
55
+ export { DaemonStatusReporter } from './status/reporter.js';
56
+
57
+ // ── Logger ──
58
+ export { LOG, installGlobalInterceptor, setLogLevel, getLogLevel, getRecentLogs } from './logging/logger.js';
59
+ export type { ScopedLogger, LogLevel, LogEntry } from './logging/logger.js';
60
+ export { logCommand, getRecentCommands } from './logging/command-log.js';
61
+
62
+ // ── CLI Management ──
63
+ export { DaemonCliManager } from './commands/cli-manager.js';
64
+
65
+ // ── Launch ──
66
+ export { launchWithCdp, getAvailableIdeIds } from './launch.js';
67
+
68
+ // ── IPC ──
69
+ export { DEFAULT_DAEMON_PORT, DAEMON_WS_PATH } from './ipc-protocol.js';
70
+
71
+ // ── Chat History ──
72
+ export { readChatHistory } from './config/chat-history.js';
73
+
74
+ // ── Agent Stream ──
75
+ export { DaemonAgentStreamManager } from './agent-stream/index.js';
76
+ export { AgentStreamPoller } from './agent-stream/index.js';
77
+ export type { AgentStreamPollerDeps } from './agent-stream/index.js';
78
+
79
+ // ── Providers ──
80
+ export { ProviderLoader } from './providers/provider-loader.js';
81
+ export { ProviderInstanceManager } from './providers/provider-instance-manager.js';
82
+ export { IdeProviderInstance } from './providers/ide-provider-instance.js';
83
+ export { CliProviderInstance } from './providers/cli-provider-instance.js';
84
+ export { AcpProviderInstance } from './providers/acp-provider-instance.js';
85
+ export type { ProviderModule, CdpTargetFilter } from './providers/contracts.js';
86
+ export { VersionArchive, detectAllVersions } from './providers/version-archive.js';
87
+ export type { ProviderVersionInfo, VersionHistory } from './providers/version-archive.js';
88
+
89
+ // ── Dev Server ──
90
+ export { DevServer } from './daemon/dev-server.js';
91
+
92
+ // ── CLI Adapters ──
93
+ export { ProviderCliAdapter } from './cli-adapters/provider-cli-adapter.js';
94
+ export type { CliAdapter } from './cli-adapter-types.js';
95
+
96
+ // ── Installer ──
97
+ export { getAIExtensions, installExtensions, launchIDE, isExtensionInstalled } from './installer.js';
98
+ export type { ExtensionInfo as InstallerExtensionInfo } from './installer.js';
99
+
100
+ // ── Boot / Lifecycle ──
101
+ export { initDaemonComponents, shutdownDaemonComponents } from './boot/daemon-lifecycle.js';
102
+ export type { DaemonInitConfig, DaemonComponents } from './boot/daemon-lifecycle.js';
103
+
@@ -0,0 +1,263 @@
1
+ /**
2
+ * ADHDev Launcher — Extension Installer
3
+ *
4
+ * Installs VS Code extensions via CLI commands.
5
+ * Supports installing user-selected AI extensions.
6
+ */
7
+
8
+ import { execSync, exec } from 'child_process';
9
+ import { IDEInfo } from './detection/ide-detector.js';
10
+
11
+ export interface ExtensionInfo {
12
+ id: string;
13
+ name: string;
14
+ displayName: string;
15
+ marketplaceId: string;
16
+ description: string;
17
+ category: 'ai-agent' | 'utility';
18
+ icon: string;
19
+ recommended: boolean;
20
+ requiresApiKey?: boolean;
21
+ apiKeyName?: string;
22
+ website?: string;
23
+ vsixUrl?: string; // VSIX download URL (used instead of marketplace)
24
+ }
25
+
26
+ /** Available extensions catalog */
27
+ export const EXTENSION_CATALOG: ExtensionInfo[] = [
28
+ // AI Agent extensions
29
+ {
30
+ id: 'roo-code',
31
+ name: 'Roo Code',
32
+ displayName: 'Roo Code (Roo Cline)',
33
+ marketplaceId: 'rooveterinaryinc.roo-cline',
34
+ description: 'Open-source AI coding assistant with multiple modes',
35
+ category: 'ai-agent',
36
+ icon: '🦘',
37
+ recommended: true,
38
+ website: 'https://roocode.com',
39
+ },
40
+ {
41
+ id: 'github-copilot',
42
+ name: 'GitHub Copilot',
43
+ displayName: 'GitHub Copilot',
44
+ marketplaceId: 'github.copilot',
45
+ description: 'AI pair programmer by GitHub',
46
+ category: 'ai-agent',
47
+ icon: '🤖',
48
+ recommended: true,
49
+ requiresApiKey: true,
50
+ apiKeyName: 'GitHub account',
51
+ website: 'https://github.com/features/copilot',
52
+ },
53
+ {
54
+ id: 'copilot-chat',
55
+ name: 'GitHub Copilot Chat',
56
+ displayName: 'GitHub Copilot Chat',
57
+ marketplaceId: 'github.copilot-chat',
58
+ description: 'Chat interface for GitHub Copilot',
59
+ category: 'ai-agent',
60
+ icon: '💬',
61
+ recommended: true,
62
+ requiresApiKey: true,
63
+ apiKeyName: 'GitHub account',
64
+ },
65
+ {
66
+ id: 'cline',
67
+ name: 'Cline',
68
+ displayName: 'Cline',
69
+ marketplaceId: 'saoudrizwan.claude-dev',
70
+ description: 'Autonomous AI coding agent in your IDE',
71
+ category: 'ai-agent',
72
+ icon: '🧠',
73
+ recommended: false,
74
+ requiresApiKey: true,
75
+ apiKeyName: 'Anthropic/OpenAI API key',
76
+ },
77
+ {
78
+ id: 'continue',
79
+ name: 'Continue',
80
+ displayName: 'Continue',
81
+ marketplaceId: 'continue.continue',
82
+ description: 'Open-source AI code assistant with custom models',
83
+ category: 'ai-agent',
84
+ icon: '▶️',
85
+ recommended: false,
86
+ },
87
+ {
88
+ id: 'aider',
89
+ name: 'Aider',
90
+ displayName: 'Aider',
91
+ marketplaceId: 'aider.aider',
92
+ description: 'AI pair programming in your terminal',
93
+ category: 'ai-agent',
94
+ icon: '🔧',
95
+ recommended: false,
96
+ requiresApiKey: true,
97
+ apiKeyName: 'OpenAI/Anthropic API key',
98
+ },
99
+ ];
100
+
101
+ export interface InstallResult {
102
+ extensionId: string;
103
+ marketplaceId: string;
104
+ success: boolean;
105
+ alreadyInstalled: boolean;
106
+ error?: string;
107
+ }
108
+
109
+ /**
110
+ * Check if an extension is already installed
111
+ */
112
+ export function isExtensionInstalled(
113
+ ide: IDEInfo,
114
+ marketplaceId: string
115
+ ): boolean {
116
+ if (!ide.cliCommand) return false;
117
+
118
+ try {
119
+ const result = execSync(`"${ide.cliCommand}" --list-extensions`, {
120
+ encoding: 'utf-8',
121
+ timeout: 15000,
122
+ stdio: ['pipe', 'pipe', 'pipe'],
123
+ });
124
+
125
+ const installed = result
126
+ .trim()
127
+ .split('\n')
128
+ .map((e) => e.trim().toLowerCase());
129
+ return installed.includes(marketplaceId.toLowerCase());
130
+ } catch {
131
+ return false;
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Install a single extension
137
+ */
138
+ export async function installExtension(
139
+ ide: IDEInfo,
140
+ extension: ExtensionInfo
141
+ ): Promise<InstallResult> {
142
+ if (!ide.cliCommand) {
143
+ return {
144
+ extensionId: extension.id,
145
+ marketplaceId: extension.marketplaceId,
146
+ success: false,
147
+ alreadyInstalled: false,
148
+ error: `No CLI command found for ${ide.displayName}. Please install it manually.`,
149
+ };
150
+ }
151
+
152
+ // Check if already installed
153
+ const alreadyInstalled = isExtensionInstalled(ide, extension.marketplaceId);
154
+ if (alreadyInstalled) {
155
+ return {
156
+ extensionId: extension.id,
157
+ marketplaceId: extension.marketplaceId,
158
+ success: true,
159
+ alreadyInstalled: true,
160
+ };
161
+ }
162
+
163
+ // If VSIX URL is available, download and install
164
+ if (extension.vsixUrl) {
165
+ try {
166
+ const tmpDir = (await import('os')).tmpdir();
167
+ const vsixPath = `${tmpDir}/adhdev-extension-latest.vsix`;
168
+
169
+ // download
170
+ const res = await fetch(extension.vsixUrl);
171
+ if (res.ok) {
172
+ const buffer = Buffer.from(await res.arrayBuffer());
173
+ const fs = await import('fs');
174
+ fs.writeFileSync(vsixPath, buffer);
175
+
176
+ // Install VSIX
177
+ return new Promise((resolve) => {
178
+ const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
179
+ exec(cmd, { timeout: 60000 }, (error, _stdout, stderr) => {
180
+ resolve({
181
+ extensionId: extension.id,
182
+ marketplaceId: extension.marketplaceId,
183
+ success: !error,
184
+ alreadyInstalled: false,
185
+ error: error ? (stderr || error.message) : undefined,
186
+ });
187
+ });
188
+ });
189
+ }
190
+ // Fall back to marketplace install if VSIX download fails
191
+ } catch (e: any) {
192
+ // Fall back to marketplace install if VSIX download fails
193
+ }
194
+ }
195
+
196
+ // Install via CLI (marketplace)
197
+ return new Promise((resolve) => {
198
+ const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
199
+
200
+ exec(cmd, { timeout: 60000 }, (error, stdout, stderr) => {
201
+ if (error) {
202
+ resolve({
203
+ extensionId: extension.id,
204
+ marketplaceId: extension.marketplaceId,
205
+ success: false,
206
+ alreadyInstalled: false,
207
+ error: stderr || error.message,
208
+ });
209
+ } else {
210
+ resolve({
211
+ extensionId: extension.id,
212
+ marketplaceId: extension.marketplaceId,
213
+ success: true,
214
+ alreadyInstalled: false,
215
+ });
216
+ }
217
+ });
218
+ });
219
+ }
220
+
221
+ /**
222
+ * Install multiple extensions sequentially
223
+ */
224
+ export async function installExtensions(
225
+ ide: IDEInfo,
226
+ extensions: ExtensionInfo[],
227
+ onProgress?: (current: number, total: number, ext: ExtensionInfo, result: InstallResult) => void
228
+ ): Promise<InstallResult[]> {
229
+ const results: InstallResult[] = [];
230
+
231
+ for (let i = 0; i < extensions.length; i++) {
232
+ const ext = extensions[i];
233
+ const result = await installExtension(ide, ext);
234
+ results.push(result);
235
+ onProgress?.(i + 1, extensions.length, ext, result);
236
+ }
237
+
238
+ return results;
239
+ }
240
+
241
+ /**
242
+ * Get AI agent extensions
243
+ */
244
+ export function getAIExtensions(): ExtensionInfo[] {
245
+ return EXTENSION_CATALOG.filter((e) => e.category === 'ai-agent');
246
+ }
247
+
248
+
249
+
250
+ /**
251
+ * Launch IDE after installation
252
+ */
253
+ export function launchIDE(ide: IDEInfo, workspacePath?: string): boolean {
254
+ if (!ide.cliCommand) return false;
255
+
256
+ try {
257
+ const args = workspacePath ? `"${workspacePath}"` : '';
258
+ exec(`"${ide.cliCommand}" ${args}`, { timeout: 10000 });
259
+ return true;
260
+ } catch {
261
+ return false;
262
+ }
263
+ }
@@ -0,0 +1,133 @@
1
+ /**
2
+ * ADHDev IPC Protocol — Extension ↔ Daemon communication protocol
3
+ *
4
+ * Message types used when Extension and Daemon communicate via localhost WS.
5
+ * Defined in core package for import from both sides.
6
+ */
7
+
8
+ // ─── Extension → Daemon ─────────────────────────
9
+
10
+ /** Extension registers itself with Daemon on first connection */
11
+ export interface IpcExtRegister {
12
+ type: 'ext:register';
13
+ payload: {
14
+ ideType: string; // 'cursor' | 'vscode' | 'windsurf' | 'antigravity' | ...
15
+ ideVersion: string; // vscode.version
16
+ extensionVersion: string;
17
+ instanceId: string; // machineId + workspace hash
18
+ machineId: string; // vscode.env.machineId
19
+ workspaceFolders: { name: string; path: string }[];
20
+ };
21
+ }
22
+
23
+ /** Extension periodically send vscode status data */
24
+ export interface IpcExtStatus {
25
+ type: 'ext:status';
26
+ payload: {
27
+ activeFile: string | null;
28
+ workspaceFolders: { name: string; path: string }[];
29
+ terminals: number;
30
+ aiAgents: { id: string; name: string; status: string; version?: string }[];
31
+ // requestId unnecessary for vscode event type
32
+ };
33
+ }
34
+
35
+ /** Return Extension vscode command execution result */
36
+ export interface IpcExtCommandResult {
37
+ type: 'ext:command_result';
38
+ payload: {
39
+ requestId: string;
40
+ success: boolean;
41
+ result?: unknown;
42
+ error?: string;
43
+ };
44
+ }
45
+
46
+ /** VSCode event occurring from Extension */
47
+ export interface IpcExtEvent {
48
+ type: 'ext:event';
49
+ payload: {
50
+ event: 'file_changed' | 'terminal_opened' | 'terminal_closed' | 'agent_status_changed';
51
+ data: Record<string, unknown>;
52
+ };
53
+ }
54
+
55
+ // ─── Daemon → Extension ─────────────────────────
56
+
57
+ /** Welcome message on Daemon-Extension connection */
58
+ export interface IpcDaemonWelcome {
59
+ type: 'daemon:welcome';
60
+ payload: {
61
+ daemonVersion: string;
62
+ serverConnected: boolean;
63
+ cdpConnected: boolean;
64
+ localPort: number;
65
+ cliAgents: string[]; // Currently running CLI agents
66
+ };
67
+ }
68
+
69
+ /** Daemon to Extension vscode Request command execution */
70
+ export interface IpcDaemonExecuteVscode {
71
+ type: 'daemon:execute_vscode';
72
+ payload: {
73
+ requestId: string;
74
+ command: string; // 'workbench.action.chat.open' etc
75
+ args?: unknown[];
76
+ };
77
+ }
78
+
79
+ /** Daemon to Extension status data request */
80
+ export interface IpcDaemonRequestStatus {
81
+ type: 'daemon:request_status';
82
+ payload: {};
83
+ }
84
+
85
+ /** Daemon notifies Extension about server connection status */
86
+ export interface IpcDaemonServerState {
87
+ type: 'daemon:server_state';
88
+ payload: {
89
+ connected: boolean;
90
+ serverUrl: string;
91
+ };
92
+ }
93
+
94
+ /** Daemon to Extension notification display request */
95
+ export interface IpcDaemonNotify {
96
+ type: 'daemon:notify';
97
+ payload: {
98
+ level: 'info' | 'warning' | 'error';
99
+ message: string;
100
+ };
101
+ }
102
+
103
+ /** Extension requests Daemon to execute command (e.g. CLI launch) */
104
+ export interface IpcExtCommand {
105
+ type: 'ext:command';
106
+ payload: {
107
+ command: string;
108
+ args?: any;
109
+ };
110
+ }
111
+
112
+ // ─── Union Types ─────────────────────────────────
113
+
114
+ export type ExtToDaemonMessage =
115
+ | IpcExtRegister
116
+ | IpcExtStatus
117
+ | IpcExtCommandResult
118
+ | IpcExtEvent
119
+ | IpcExtCommand;
120
+
121
+ export type DaemonToExtMessage =
122
+ | IpcDaemonWelcome
123
+ | IpcDaemonExecuteVscode
124
+ | IpcDaemonRequestStatus
125
+ | IpcDaemonServerState
126
+ | IpcDaemonNotify;
127
+
128
+ export type IpcMessage = ExtToDaemonMessage | DaemonToExtMessage;
129
+
130
+ // ─── Constants ───────────────────────────────────
131
+
132
+ export const DEFAULT_DAEMON_PORT = 19222;
133
+ export const DAEMON_WS_PATH = '/ipc';