@cleocode/adapters 2.0.0

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 +27 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +1927 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/providers/claude-code/adapter.d.ts +75 -0
  6. package/dist/providers/claude-code/adapter.d.ts.map +1 -0
  7. package/dist/providers/claude-code/adapter.js +154 -0
  8. package/dist/providers/claude-code/adapter.js.map +1 -0
  9. package/dist/providers/claude-code/context-monitor.d.ts +24 -0
  10. package/dist/providers/claude-code/context-monitor.d.ts.map +1 -0
  11. package/dist/providers/claude-code/context-monitor.js +148 -0
  12. package/dist/providers/claude-code/context-monitor.js.map +1 -0
  13. package/dist/providers/claude-code/hooks.d.ts +59 -0
  14. package/dist/providers/claude-code/hooks.d.ts.map +1 -0
  15. package/dist/providers/claude-code/hooks.js +77 -0
  16. package/dist/providers/claude-code/hooks.js.map +1 -0
  17. package/dist/providers/claude-code/index.d.ts +24 -0
  18. package/dist/providers/claude-code/index.d.ts.map +1 -0
  19. package/dist/providers/claude-code/index.js +26 -0
  20. package/dist/providers/claude-code/index.js.map +1 -0
  21. package/dist/providers/claude-code/install.d.ts +75 -0
  22. package/dist/providers/claude-code/install.d.ts.map +1 -0
  23. package/dist/providers/claude-code/install.js +237 -0
  24. package/dist/providers/claude-code/install.js.map +1 -0
  25. package/dist/providers/claude-code/paths.d.ts +24 -0
  26. package/dist/providers/claude-code/paths.d.ts.map +1 -0
  27. package/dist/providers/claude-code/paths.js +33 -0
  28. package/dist/providers/claude-code/paths.js.map +1 -0
  29. package/dist/providers/claude-code/spawn.d.ts +60 -0
  30. package/dist/providers/claude-code/spawn.d.ts.map +1 -0
  31. package/dist/providers/claude-code/spawn.js +160 -0
  32. package/dist/providers/claude-code/spawn.js.map +1 -0
  33. package/dist/providers/claude-code/statusline.d.ts +24 -0
  34. package/dist/providers/claude-code/statusline.d.ts.map +1 -0
  35. package/dist/providers/claude-code/statusline.js +85 -0
  36. package/dist/providers/claude-code/statusline.js.map +1 -0
  37. package/dist/providers/claude-code/task-sync.d.ts +27 -0
  38. package/dist/providers/claude-code/task-sync.d.ts.map +1 -0
  39. package/dist/providers/claude-code/task-sync.js +124 -0
  40. package/dist/providers/claude-code/task-sync.js.map +1 -0
  41. package/dist/providers/claude-code/transport.d.ts +14 -0
  42. package/dist/providers/claude-code/transport.d.ts.map +1 -0
  43. package/dist/providers/claude-code/transport.js +18 -0
  44. package/dist/providers/claude-code/transport.js.map +1 -0
  45. package/dist/providers/cursor/adapter.d.ts +62 -0
  46. package/dist/providers/cursor/adapter.d.ts.map +1 -0
  47. package/dist/providers/cursor/adapter.js +124 -0
  48. package/dist/providers/cursor/adapter.js.map +1 -0
  49. package/dist/providers/cursor/hooks.d.ts +48 -0
  50. package/dist/providers/cursor/hooks.d.ts.map +1 -0
  51. package/dist/providers/cursor/hooks.js +55 -0
  52. package/dist/providers/cursor/hooks.js.map +1 -0
  53. package/dist/providers/cursor/index.d.ts +19 -0
  54. package/dist/providers/cursor/index.d.ts.map +1 -0
  55. package/dist/providers/cursor/index.js +21 -0
  56. package/dist/providers/cursor/index.js.map +1 -0
  57. package/dist/providers/cursor/install.d.ts +94 -0
  58. package/dist/providers/cursor/install.d.ts.map +1 -0
  59. package/dist/providers/cursor/install.js +241 -0
  60. package/dist/providers/cursor/install.js.map +1 -0
  61. package/dist/providers/cursor/spawn.d.ts +50 -0
  62. package/dist/providers/cursor/spawn.d.ts.map +1 -0
  63. package/dist/providers/cursor/spawn.js +59 -0
  64. package/dist/providers/cursor/spawn.js.map +1 -0
  65. package/dist/providers/opencode/adapter.d.ts +67 -0
  66. package/dist/providers/opencode/adapter.d.ts.map +1 -0
  67. package/dist/providers/opencode/adapter.js +144 -0
  68. package/dist/providers/opencode/adapter.js.map +1 -0
  69. package/dist/providers/opencode/hooks.d.ts +66 -0
  70. package/dist/providers/opencode/hooks.d.ts.map +1 -0
  71. package/dist/providers/opencode/hooks.js +89 -0
  72. package/dist/providers/opencode/hooks.js.map +1 -0
  73. package/dist/providers/opencode/index.d.ts +20 -0
  74. package/dist/providers/opencode/index.d.ts.map +1 -0
  75. package/dist/providers/opencode/index.js +22 -0
  76. package/dist/providers/opencode/index.js.map +1 -0
  77. package/dist/providers/opencode/install.d.ts +65 -0
  78. package/dist/providers/opencode/install.d.ts.map +1 -0
  79. package/dist/providers/opencode/install.js +183 -0
  80. package/dist/providers/opencode/install.js.map +1 -0
  81. package/dist/providers/opencode/spawn.d.ts +72 -0
  82. package/dist/providers/opencode/spawn.d.ts.map +1 -0
  83. package/dist/providers/opencode/spawn.js +219 -0
  84. package/dist/providers/opencode/spawn.js.map +1 -0
  85. package/dist/registry.d.ts +36 -0
  86. package/dist/registry.d.ts.map +1 -0
  87. package/dist/registry.js +55 -0
  88. package/dist/registry.js.map +1 -0
  89. package/package.json +32 -0
  90. package/src/index.d.ts +27 -0
  91. package/src/index.d.ts.map +1 -0
  92. package/src/index.js +28 -0
  93. package/src/index.js.map +1 -0
  94. package/src/index.ts +37 -0
  95. package/src/providers/claude-code/__tests__/adapter.test.d.ts +7 -0
  96. package/src/providers/claude-code/__tests__/adapter.test.d.ts.map +1 -0
  97. package/src/providers/claude-code/__tests__/adapter.test.js +249 -0
  98. package/src/providers/claude-code/__tests__/adapter.test.js.map +1 -0
  99. package/src/providers/claude-code/__tests__/adapter.test.ts +291 -0
  100. package/src/providers/claude-code/adapter.d.ts +75 -0
  101. package/src/providers/claude-code/adapter.d.ts.map +1 -0
  102. package/src/providers/claude-code/adapter.js +154 -0
  103. package/src/providers/claude-code/adapter.js.map +1 -0
  104. package/src/providers/claude-code/adapter.ts +175 -0
  105. package/src/providers/claude-code/context-monitor.d.ts +24 -0
  106. package/src/providers/claude-code/context-monitor.d.ts.map +1 -0
  107. package/src/providers/claude-code/context-monitor.js +148 -0
  108. package/src/providers/claude-code/context-monitor.js.map +1 -0
  109. package/src/providers/claude-code/context-monitor.ts +175 -0
  110. package/src/providers/claude-code/hooks.d.ts +59 -0
  111. package/src/providers/claude-code/hooks.d.ts.map +1 -0
  112. package/src/providers/claude-code/hooks.js +77 -0
  113. package/src/providers/claude-code/hooks.js.map +1 -0
  114. package/src/providers/claude-code/hooks.ts +85 -0
  115. package/src/providers/claude-code/index.d.ts +24 -0
  116. package/src/providers/claude-code/index.d.ts.map +1 -0
  117. package/src/providers/claude-code/index.js +26 -0
  118. package/src/providers/claude-code/index.js.map +1 -0
  119. package/src/providers/claude-code/index.ts +33 -0
  120. package/src/providers/claude-code/install.d.ts +75 -0
  121. package/src/providers/claude-code/install.d.ts.map +1 -0
  122. package/src/providers/claude-code/install.js +237 -0
  123. package/src/providers/claude-code/install.js.map +1 -0
  124. package/src/providers/claude-code/install.ts +267 -0
  125. package/src/providers/claude-code/manifest.json +26 -0
  126. package/src/providers/claude-code/paths.d.ts +24 -0
  127. package/src/providers/claude-code/paths.d.ts.map +1 -0
  128. package/src/providers/claude-code/paths.js +33 -0
  129. package/src/providers/claude-code/paths.js.map +1 -0
  130. package/src/providers/claude-code/paths.ts +38 -0
  131. package/src/providers/claude-code/spawn.d.ts +60 -0
  132. package/src/providers/claude-code/spawn.d.ts.map +1 -0
  133. package/src/providers/claude-code/spawn.js +160 -0
  134. package/src/providers/claude-code/spawn.js.map +1 -0
  135. package/src/providers/claude-code/spawn.ts +178 -0
  136. package/src/providers/claude-code/statusline.d.ts +24 -0
  137. package/src/providers/claude-code/statusline.d.ts.map +1 -0
  138. package/src/providers/claude-code/statusline.js +85 -0
  139. package/src/providers/claude-code/statusline.js.map +1 -0
  140. package/src/providers/claude-code/statusline.ts +99 -0
  141. package/src/providers/claude-code/task-sync.d.ts +27 -0
  142. package/src/providers/claude-code/task-sync.d.ts.map +1 -0
  143. package/src/providers/claude-code/task-sync.js +124 -0
  144. package/src/providers/claude-code/task-sync.js.map +1 -0
  145. package/src/providers/claude-code/task-sync.ts +158 -0
  146. package/src/providers/claude-code/transport.d.ts +14 -0
  147. package/src/providers/claude-code/transport.d.ts.map +1 -0
  148. package/src/providers/claude-code/transport.js +18 -0
  149. package/src/providers/claude-code/transport.js.map +1 -0
  150. package/src/providers/claude-code/transport.ts +21 -0
  151. package/src/providers/cursor/__tests__/adapter.test.d.ts +7 -0
  152. package/src/providers/cursor/__tests__/adapter.test.d.ts.map +1 -0
  153. package/src/providers/cursor/__tests__/adapter.test.js +246 -0
  154. package/src/providers/cursor/__tests__/adapter.test.js.map +1 -0
  155. package/src/providers/cursor/__tests__/adapter.test.ts +291 -0
  156. package/src/providers/cursor/adapter.d.ts +62 -0
  157. package/src/providers/cursor/adapter.d.ts.map +1 -0
  158. package/src/providers/cursor/adapter.js +124 -0
  159. package/src/providers/cursor/adapter.js.map +1 -0
  160. package/src/providers/cursor/adapter.ts +145 -0
  161. package/src/providers/cursor/hooks.d.ts +48 -0
  162. package/src/providers/cursor/hooks.d.ts.map +1 -0
  163. package/src/providers/cursor/hooks.js +55 -0
  164. package/src/providers/cursor/hooks.js.map +1 -0
  165. package/src/providers/cursor/hooks.ts +61 -0
  166. package/src/providers/cursor/index.d.ts +19 -0
  167. package/src/providers/cursor/index.d.ts.map +1 -0
  168. package/src/providers/cursor/index.js +21 -0
  169. package/src/providers/cursor/index.js.map +1 -0
  170. package/src/providers/cursor/index.ts +24 -0
  171. package/src/providers/cursor/install.d.ts +94 -0
  172. package/src/providers/cursor/install.d.ts.map +1 -0
  173. package/src/providers/cursor/install.js +241 -0
  174. package/src/providers/cursor/install.js.map +1 -0
  175. package/src/providers/cursor/install.ts +271 -0
  176. package/src/providers/cursor/manifest.json +26 -0
  177. package/src/providers/cursor/spawn.d.ts +50 -0
  178. package/src/providers/cursor/spawn.d.ts.map +1 -0
  179. package/src/providers/cursor/spawn.js +59 -0
  180. package/src/providers/cursor/spawn.js.map +1 -0
  181. package/src/providers/cursor/spawn.ts +66 -0
  182. package/src/providers/opencode/__tests__/adapter.test.d.ts +7 -0
  183. package/src/providers/opencode/__tests__/adapter.test.d.ts.map +1 -0
  184. package/src/providers/opencode/__tests__/adapter.test.js +263 -0
  185. package/src/providers/opencode/__tests__/adapter.test.js.map +1 -0
  186. package/src/providers/opencode/__tests__/adapter.test.ts +309 -0
  187. package/src/providers/opencode/adapter.d.ts +67 -0
  188. package/src/providers/opencode/adapter.d.ts.map +1 -0
  189. package/src/providers/opencode/adapter.js +144 -0
  190. package/src/providers/opencode/adapter.js.map +1 -0
  191. package/src/providers/opencode/adapter.ts +165 -0
  192. package/src/providers/opencode/hooks.d.ts +66 -0
  193. package/src/providers/opencode/hooks.d.ts.map +1 -0
  194. package/src/providers/opencode/hooks.js +89 -0
  195. package/src/providers/opencode/hooks.js.map +1 -0
  196. package/src/providers/opencode/hooks.ts +97 -0
  197. package/src/providers/opencode/index.d.ts +20 -0
  198. package/src/providers/opencode/index.d.ts.map +1 -0
  199. package/src/providers/opencode/index.js +22 -0
  200. package/src/providers/opencode/index.js.map +1 -0
  201. package/src/providers/opencode/index.ts +25 -0
  202. package/src/providers/opencode/install.d.ts +65 -0
  203. package/src/providers/opencode/install.d.ts.map +1 -0
  204. package/src/providers/opencode/install.js +183 -0
  205. package/src/providers/opencode/install.js.map +1 -0
  206. package/src/providers/opencode/install.ts +206 -0
  207. package/src/providers/opencode/manifest.json +26 -0
  208. package/src/providers/opencode/spawn.d.ts +72 -0
  209. package/src/providers/opencode/spawn.d.ts.map +1 -0
  210. package/src/providers/opencode/spawn.js +219 -0
  211. package/src/providers/opencode/spawn.js.map +1 -0
  212. package/src/providers/opencode/spawn.ts +253 -0
  213. package/src/registry.d.ts +36 -0
  214. package/src/registry.d.ts.map +1 -0
  215. package/src/registry.js +55 -0
  216. package/src/registry.js.map +1 -0
  217. package/src/registry.ts +81 -0
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Cursor Install Provider
3
+ *
4
+ * Handles CLEO installation into Cursor environments:
5
+ * - Registers CLEO MCP server in .cursor/mcp.json
6
+ * - Ensures .cursorrules has CLEO @-references (legacy format)
7
+ * - Creates .cursor/rules/cleo.mdc with CLEO references (modern format)
8
+ *
9
+ * Cursor supports two instruction file formats:
10
+ * 1. Legacy: .cursorrules (flat file, project root)
11
+ * 2. Modern: .cursor/rules/*.mdc (MDC format, per-rule files)
12
+ *
13
+ * This provider writes to both for maximum compatibility.
14
+ *
15
+ * @task T5240
16
+ */
17
+
18
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
19
+ import { join } from 'node:path';
20
+ import type { AdapterInstallProvider, InstallOptions, InstallResult } from '@cleocode/contracts';
21
+
22
+ /** Lines that should appear in instruction files to reference CLEO. */
23
+ const INSTRUCTION_REFERENCES = [
24
+ '@~/.cleo/templates/CLEO-INJECTION.md',
25
+ '@.cleo/memory-bridge.md',
26
+ ];
27
+
28
+ /** MCP server registration key used in Cursor config. */
29
+ const MCP_SERVER_KEY = 'cleo';
30
+
31
+ /**
32
+ * Install provider for Cursor.
33
+ *
34
+ * Manages CLEO's integration with Cursor by:
35
+ * 1. Registering the CLEO MCP server in .cursor/mcp.json
36
+ * 2. Creating/updating .cursorrules with @-references (legacy)
37
+ * 3. Creating .cursor/rules/cleo.mdc with @-references (modern)
38
+ */
39
+ export class CursorInstallProvider implements AdapterInstallProvider {
40
+ private installedProjectDir: string | null = null;
41
+
42
+ /**
43
+ * Install CLEO into a Cursor project.
44
+ *
45
+ * @param options - Installation options including project directory and MCP server path
46
+ * @returns Result describing what was installed
47
+ */
48
+ async install(options: InstallOptions): Promise<InstallResult> {
49
+ const { projectDir, mcpServerPath } = options;
50
+ const installedAt = new Date().toISOString();
51
+ let instructionFileUpdated = false;
52
+ let mcpRegistered = false;
53
+ const details: Record<string, unknown> = {};
54
+
55
+ // Step 1: Register MCP server in .cursor/mcp.json
56
+ if (mcpServerPath) {
57
+ mcpRegistered = this.registerMcpServer(projectDir, mcpServerPath);
58
+ if (mcpRegistered) {
59
+ details.mcpConfigPath = join(projectDir, '.cursor', 'mcp.json');
60
+ }
61
+ }
62
+
63
+ // Step 2: Ensure instruction files have @-references
64
+ instructionFileUpdated = this.updateInstructionFiles(projectDir);
65
+ if (instructionFileUpdated) {
66
+ details.instructionFiles = this.getUpdatedFileList(projectDir);
67
+ }
68
+
69
+ this.installedProjectDir = projectDir;
70
+
71
+ return {
72
+ success: true,
73
+ installedAt,
74
+ instructionFileUpdated,
75
+ mcpRegistered,
76
+ details,
77
+ };
78
+ }
79
+
80
+ /**
81
+ * Uninstall CLEO from the current Cursor project.
82
+ *
83
+ * Removes the MCP server registration from .cursor/mcp.json.
84
+ * Does not remove instruction file references (they are harmless if CLEO is not present).
85
+ */
86
+ async uninstall(): Promise<void> {
87
+ if (!this.installedProjectDir) return;
88
+
89
+ const mcpPath = join(this.installedProjectDir, '.cursor', 'mcp.json');
90
+ if (existsSync(mcpPath)) {
91
+ try {
92
+ const raw = readFileSync(mcpPath, 'utf-8');
93
+ const config = JSON.parse(raw) as Record<string, unknown>;
94
+ const mcpServers = config.mcpServers as Record<string, unknown> | undefined;
95
+ if (mcpServers && MCP_SERVER_KEY in mcpServers) {
96
+ delete mcpServers[MCP_SERVER_KEY];
97
+ writeFileSync(mcpPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
98
+ }
99
+ } catch {
100
+ // Ignore errors during uninstall
101
+ }
102
+ }
103
+
104
+ this.installedProjectDir = null;
105
+ }
106
+
107
+ /**
108
+ * Check whether CLEO is installed in the current environment.
109
+ *
110
+ * Checks for MCP server registered in .cursor/mcp.json.
111
+ */
112
+ async isInstalled(): Promise<boolean> {
113
+ const mcpPath = join(process.cwd(), '.cursor', 'mcp.json');
114
+ if (existsSync(mcpPath)) {
115
+ try {
116
+ const config = JSON.parse(readFileSync(mcpPath, 'utf-8'));
117
+ const mcpServers = config.mcpServers as Record<string, unknown> | undefined;
118
+ if (mcpServers && MCP_SERVER_KEY in mcpServers) {
119
+ return true;
120
+ }
121
+ } catch {
122
+ // Fall through
123
+ }
124
+ }
125
+
126
+ return false;
127
+ }
128
+
129
+ /**
130
+ * Ensure instruction files contain @-references to CLEO.
131
+ *
132
+ * Updates .cursorrules (legacy) and creates .cursor/rules/cleo.mdc (modern).
133
+ *
134
+ * @param projectDir - Project root directory
135
+ */
136
+ async ensureInstructionReferences(projectDir: string): Promise<void> {
137
+ this.updateInstructionFiles(projectDir);
138
+ }
139
+
140
+ /**
141
+ * Register the CLEO MCP server in .cursor/mcp.json.
142
+ *
143
+ * Cursor stores MCP server configuration in .cursor/mcp.json
144
+ * under the mcpServers key.
145
+ *
146
+ * @returns true if registration was performed or updated
147
+ */
148
+ private registerMcpServer(projectDir: string, mcpServerPath: string): boolean {
149
+ const cursorDir = join(projectDir, '.cursor');
150
+ const mcpPath = join(cursorDir, 'mcp.json');
151
+ let config: Record<string, unknown> = {};
152
+
153
+ mkdirSync(cursorDir, { recursive: true });
154
+
155
+ if (existsSync(mcpPath)) {
156
+ try {
157
+ config = JSON.parse(readFileSync(mcpPath, 'utf-8'));
158
+ } catch {
159
+ // Start fresh on parse error
160
+ }
161
+ }
162
+
163
+ if (!config.mcpServers || typeof config.mcpServers !== 'object') {
164
+ config.mcpServers = {};
165
+ }
166
+
167
+ const mcpServers = config.mcpServers as Record<string, unknown>;
168
+ mcpServers[MCP_SERVER_KEY] = {
169
+ command: 'node',
170
+ args: [mcpServerPath],
171
+ };
172
+
173
+ writeFileSync(mcpPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
174
+ return true;
175
+ }
176
+
177
+ /**
178
+ * Update instruction files with CLEO @-references.
179
+ *
180
+ * Handles both legacy (.cursorrules) and modern (.cursor/rules/cleo.mdc) formats.
181
+ *
182
+ * @returns true if any file was created or modified
183
+ */
184
+ private updateInstructionFiles(projectDir: string): boolean {
185
+ let updated = false;
186
+
187
+ // Update legacy .cursorrules if it exists
188
+ if (this.updateLegacyRules(projectDir)) {
189
+ updated = true;
190
+ }
191
+
192
+ // Create/update modern .cursor/rules/cleo.mdc
193
+ if (this.updateModernRules(projectDir)) {
194
+ updated = true;
195
+ }
196
+
197
+ return updated;
198
+ }
199
+
200
+ /**
201
+ * Update legacy .cursorrules file with @-references.
202
+ * Only modifies the file if it already exists (does not create it).
203
+ *
204
+ * @returns true if the file was modified
205
+ */
206
+ private updateLegacyRules(projectDir: string): boolean {
207
+ const rulesPath = join(projectDir, '.cursorrules');
208
+ if (!existsSync(rulesPath)) {
209
+ return false;
210
+ }
211
+
212
+ let content = readFileSync(rulesPath, 'utf-8');
213
+ const missingRefs = INSTRUCTION_REFERENCES.filter((ref) => !content.includes(ref));
214
+
215
+ if (missingRefs.length === 0) {
216
+ return false;
217
+ }
218
+
219
+ const separator = content.endsWith('\n') ? '' : '\n';
220
+ content = content + separator + missingRefs.join('\n') + '\n';
221
+ writeFileSync(rulesPath, content, 'utf-8');
222
+ return true;
223
+ }
224
+
225
+ /**
226
+ * Create or update .cursor/rules/cleo.mdc with CLEO references.
227
+ *
228
+ * MDC (Markdown Component) format is Cursor's modern rule file format.
229
+ * Each .mdc file in .cursor/rules/ is loaded as a rule set.
230
+ *
231
+ * @returns true if the file was created or modified
232
+ */
233
+ private updateModernRules(projectDir: string): boolean {
234
+ const rulesDir = join(projectDir, '.cursor', 'rules');
235
+ const mdcPath = join(rulesDir, 'cleo.mdc');
236
+
237
+ const expectedContent = [
238
+ '---',
239
+ 'description: CLEO task management protocol references',
240
+ 'globs: "**/*"',
241
+ 'alwaysApply: true',
242
+ '---',
243
+ '',
244
+ ...INSTRUCTION_REFERENCES,
245
+ '',
246
+ ].join('\n');
247
+
248
+ if (existsSync(mdcPath)) {
249
+ const existing = readFileSync(mdcPath, 'utf-8');
250
+ if (existing === expectedContent) {
251
+ return false;
252
+ }
253
+ }
254
+
255
+ mkdirSync(rulesDir, { recursive: true });
256
+ writeFileSync(mdcPath, expectedContent, 'utf-8');
257
+ return true;
258
+ }
259
+
260
+ /**
261
+ * Get list of instruction files that were updated.
262
+ */
263
+ private getUpdatedFileList(projectDir: string): string[] {
264
+ const files: string[] = [];
265
+ if (existsSync(join(projectDir, '.cursorrules'))) {
266
+ files.push(join(projectDir, '.cursorrules'));
267
+ }
268
+ files.push(join(projectDir, '.cursor', 'rules', 'cleo.mdc'));
269
+ return files;
270
+ }
271
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "id": "cursor",
3
+ "name": "Cursor Adapter",
4
+ "version": "1.0.0",
5
+ "description": "CLEO adapter for Cursor AI code editor",
6
+ "provider": "cursor",
7
+ "entryPoint": "src/index.ts",
8
+ "capabilities": {
9
+ "supportsHooks": false,
10
+ "supportedHookEvents": [],
11
+ "supportsSpawn": false,
12
+ "supportsInstall": true,
13
+ "supportsMcp": true,
14
+ "supportsInstructionFiles": true,
15
+ "instructionFilePattern": ".cursor/rules/*.mdc",
16
+ "supportsContextMonitor": false,
17
+ "supportsStatusline": false,
18
+ "supportsProviderPaths": true,
19
+ "supportsTransport": false
20
+ },
21
+ "detectionPatterns": [
22
+ { "type": "env", "pattern": "CURSOR_EDITOR", "description": "Cursor sets this env var" },
23
+ { "type": "file", "pattern": ".cursor", "description": "Cursor config directory" },
24
+ { "type": "file", "pattern": ".cursorrules", "description": "Legacy Cursor rules file" }
25
+ ]
26
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Cursor Spawn Provider
3
+ *
4
+ * Cursor is a GUI-based AI code editor and does not support
5
+ * CLI-based subagent spawning. This provider implements
6
+ * the AdapterSpawnProvider interface with appropriate rejections.
7
+ *
8
+ * @task T5240
9
+ */
10
+ import type { AdapterSpawnProvider, SpawnContext, SpawnResult } from '@cleocode/contracts';
11
+ /**
12
+ * Spawn provider for Cursor.
13
+ *
14
+ * Cursor does not support subagent spawning via CLI. The adapter
15
+ * declares supportsSpawn: false in its capabilities. All methods
16
+ * either reject or return empty results.
17
+ */
18
+ export declare class CursorSpawnProvider implements AdapterSpawnProvider {
19
+ /**
20
+ * Check if Cursor supports spawning subagents.
21
+ *
22
+ * @returns false (Cursor does not support CLI spawning)
23
+ */
24
+ canSpawn(): Promise<boolean>;
25
+ /**
26
+ * Attempt to spawn a subagent via Cursor.
27
+ *
28
+ * Always throws because Cursor does not support subagent spawning.
29
+ * Callers should check canSpawn() before calling this method.
30
+ *
31
+ * @param _context - Unused; spawning is not supported
32
+ * @throws Error explaining that Cursor does not support subagent spawning
33
+ */
34
+ spawn(_context: SpawnContext): Promise<SpawnResult>;
35
+ /**
36
+ * List running Cursor subagent processes.
37
+ *
38
+ * @returns Empty array (no processes can be spawned)
39
+ */
40
+ listRunning(): Promise<SpawnResult[]>;
41
+ /**
42
+ * Terminate a Cursor subagent process.
43
+ *
44
+ * No-op because Cursor cannot spawn processes.
45
+ *
46
+ * @param _instanceId - Unused; no processes to terminate
47
+ */
48
+ terminate(_instanceId: string): Promise<void>;
49
+ }
50
+ //# sourceMappingURL=spawn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE3F;;;;;;GAMG;AACH,qBAAa,mBAAoB,YAAW,oBAAoB;IAC9D;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC;;;;;;;;OAQG;IACG,KAAK,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAQzD;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAI3C;;;;;;OAMG;IACG,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGpD"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Cursor Spawn Provider
3
+ *
4
+ * Cursor is a GUI-based AI code editor and does not support
5
+ * CLI-based subagent spawning. This provider implements
6
+ * the AdapterSpawnProvider interface with appropriate rejections.
7
+ *
8
+ * @task T5240
9
+ */
10
+ /**
11
+ * Spawn provider for Cursor.
12
+ *
13
+ * Cursor does not support subagent spawning via CLI. The adapter
14
+ * declares supportsSpawn: false in its capabilities. All methods
15
+ * either reject or return empty results.
16
+ */
17
+ export class CursorSpawnProvider {
18
+ /**
19
+ * Check if Cursor supports spawning subagents.
20
+ *
21
+ * @returns false (Cursor does not support CLI spawning)
22
+ */
23
+ async canSpawn() {
24
+ return false;
25
+ }
26
+ /**
27
+ * Attempt to spawn a subagent via Cursor.
28
+ *
29
+ * Always throws because Cursor does not support subagent spawning.
30
+ * Callers should check canSpawn() before calling this method.
31
+ *
32
+ * @param _context - Unused; spawning is not supported
33
+ * @throws Error explaining that Cursor does not support subagent spawning
34
+ */
35
+ async spawn(_context) {
36
+ throw new Error('Cursor does not support subagent spawning. ' +
37
+ 'Cursor is a GUI-based editor without CLI subagent capabilities. ' +
38
+ 'Use a provider that supports spawning (e.g., Claude Code or OpenCode).');
39
+ }
40
+ /**
41
+ * List running Cursor subagent processes.
42
+ *
43
+ * @returns Empty array (no processes can be spawned)
44
+ */
45
+ async listRunning() {
46
+ return [];
47
+ }
48
+ /**
49
+ * Terminate a Cursor subagent process.
50
+ *
51
+ * No-op because Cursor cannot spawn processes.
52
+ *
53
+ * @param _instanceId - Unused; no processes to terminate
54
+ */
55
+ async terminate(_instanceId) {
56
+ // No-op: Cursor does not spawn processes.
57
+ }
58
+ }
59
+ //# sourceMappingURL=spawn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.js","sourceRoot":"","sources":["spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IAC9B;;;;OAIG;IACH,KAAK,CAAC,QAAQ;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,CAAC,QAAsB;QAChC,MAAM,IAAI,KAAK,CACb,6CAA6C;YAC7C,kEAAkE;YAClE,wEAAwE,CACzE,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,SAAS,CAAC,WAAmB;QACjC,0CAA0C;IAC5C,CAAC;CACF"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Cursor Spawn Provider
3
+ *
4
+ * Cursor is a GUI-based AI code editor and does not support
5
+ * CLI-based subagent spawning. This provider implements
6
+ * the AdapterSpawnProvider interface with appropriate rejections.
7
+ *
8
+ * @task T5240
9
+ */
10
+
11
+ import type { AdapterSpawnProvider, SpawnContext, SpawnResult } from '@cleocode/contracts';
12
+
13
+ /**
14
+ * Spawn provider for Cursor.
15
+ *
16
+ * Cursor does not support subagent spawning via CLI. The adapter
17
+ * declares supportsSpawn: false in its capabilities. All methods
18
+ * either reject or return empty results.
19
+ */
20
+ export class CursorSpawnProvider implements AdapterSpawnProvider {
21
+ /**
22
+ * Check if Cursor supports spawning subagents.
23
+ *
24
+ * @returns false (Cursor does not support CLI spawning)
25
+ */
26
+ async canSpawn(): Promise<boolean> {
27
+ return false;
28
+ }
29
+
30
+ /**
31
+ * Attempt to spawn a subagent via Cursor.
32
+ *
33
+ * Always throws because Cursor does not support subagent spawning.
34
+ * Callers should check canSpawn() before calling this method.
35
+ *
36
+ * @param _context - Unused; spawning is not supported
37
+ * @throws Error explaining that Cursor does not support subagent spawning
38
+ */
39
+ async spawn(_context: SpawnContext): Promise<SpawnResult> {
40
+ throw new Error(
41
+ 'Cursor does not support subagent spawning. ' +
42
+ 'Cursor is a GUI-based editor without CLI subagent capabilities. ' +
43
+ 'Use a provider that supports spawning (e.g., Claude Code or OpenCode).',
44
+ );
45
+ }
46
+
47
+ /**
48
+ * List running Cursor subagent processes.
49
+ *
50
+ * @returns Empty array (no processes can be spawned)
51
+ */
52
+ async listRunning(): Promise<SpawnResult[]> {
53
+ return [];
54
+ }
55
+
56
+ /**
57
+ * Terminate a Cursor subagent process.
58
+ *
59
+ * No-op because Cursor cannot spawn processes.
60
+ *
61
+ * @param _instanceId - Unused; no processes to terminate
62
+ */
63
+ async terminate(_instanceId: string): Promise<void> {
64
+ // No-op: Cursor does not spawn processes.
65
+ }
66
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tests for the OpenCode adapter package.
3
+ *
4
+ * @task T5240
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=adapter.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.test.d.ts","sourceRoot":"","sources":["adapter.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}