@cleocode/adapters 2026.3.72 → 2026.3.74

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 (96) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1227 -101
  4. package/dist/index.js.map +4 -4
  5. package/dist/providers/claude-code/adapter.d.ts.map +1 -1
  6. package/dist/providers/claude-code/adapter.js +16 -5
  7. package/dist/providers/claude-code/adapter.js.map +1 -1
  8. package/dist/providers/claude-code/hooks.d.ts +89 -25
  9. package/dist/providers/claude-code/hooks.d.ts.map +1 -1
  10. package/dist/providers/claude-code/hooks.js +230 -28
  11. package/dist/providers/claude-code/hooks.js.map +1 -1
  12. package/dist/providers/codex/adapter.d.ts +70 -0
  13. package/dist/providers/codex/adapter.d.ts.map +1 -0
  14. package/dist/providers/codex/adapter.js +134 -0
  15. package/dist/providers/codex/adapter.js.map +1 -0
  16. package/dist/providers/codex/hooks.d.ts +85 -0
  17. package/dist/providers/codex/hooks.d.ts.map +1 -0
  18. package/dist/providers/codex/hooks.js +155 -0
  19. package/dist/providers/codex/hooks.js.map +1 -0
  20. package/dist/providers/codex/index.d.ts +22 -0
  21. package/dist/providers/codex/index.d.ts.map +1 -0
  22. package/dist/providers/codex/index.js +24 -0
  23. package/dist/providers/codex/index.js.map +1 -0
  24. package/dist/providers/codex/install.d.ts +74 -0
  25. package/dist/providers/codex/install.d.ts.map +1 -0
  26. package/dist/providers/codex/install.js +183 -0
  27. package/dist/providers/codex/install.js.map +1 -0
  28. package/dist/providers/cursor/adapter.d.ts.map +1 -1
  29. package/dist/providers/cursor/adapter.js +16 -2
  30. package/dist/providers/cursor/adapter.js.map +1 -1
  31. package/dist/providers/cursor/hooks.d.ts +102 -17
  32. package/dist/providers/cursor/hooks.d.ts.map +1 -1
  33. package/dist/providers/cursor/hooks.js +164 -18
  34. package/dist/providers/cursor/hooks.js.map +1 -1
  35. package/dist/providers/gemini-cli/adapter.d.ts +70 -0
  36. package/dist/providers/gemini-cli/adapter.d.ts.map +1 -0
  37. package/dist/providers/gemini-cli/adapter.js +145 -0
  38. package/dist/providers/gemini-cli/adapter.js.map +1 -0
  39. package/dist/providers/gemini-cli/hooks.d.ts +92 -0
  40. package/dist/providers/gemini-cli/hooks.d.ts.map +1 -0
  41. package/dist/providers/gemini-cli/hooks.js +169 -0
  42. package/dist/providers/gemini-cli/hooks.js.map +1 -0
  43. package/dist/providers/gemini-cli/index.d.ts +22 -0
  44. package/dist/providers/gemini-cli/index.d.ts.map +1 -0
  45. package/dist/providers/gemini-cli/index.js +24 -0
  46. package/dist/providers/gemini-cli/index.js.map +1 -0
  47. package/dist/providers/gemini-cli/install.d.ts +74 -0
  48. package/dist/providers/gemini-cli/install.d.ts.map +1 -0
  49. package/dist/providers/gemini-cli/install.js +183 -0
  50. package/dist/providers/gemini-cli/install.js.map +1 -0
  51. package/dist/providers/kimi/adapter.d.ts +72 -0
  52. package/dist/providers/kimi/adapter.d.ts.map +1 -0
  53. package/dist/providers/kimi/adapter.js +133 -0
  54. package/dist/providers/kimi/adapter.js.map +1 -0
  55. package/dist/providers/kimi/hooks.d.ts +64 -0
  56. package/dist/providers/kimi/hooks.d.ts.map +1 -0
  57. package/dist/providers/kimi/hooks.js +73 -0
  58. package/dist/providers/kimi/hooks.js.map +1 -0
  59. package/dist/providers/kimi/index.d.ts +22 -0
  60. package/dist/providers/kimi/index.d.ts.map +1 -0
  61. package/dist/providers/kimi/index.js +24 -0
  62. package/dist/providers/kimi/index.js.map +1 -0
  63. package/dist/providers/kimi/install.d.ts +80 -0
  64. package/dist/providers/kimi/install.d.ts.map +1 -0
  65. package/dist/providers/kimi/install.js +189 -0
  66. package/dist/providers/kimi/install.js.map +1 -0
  67. package/dist/providers/opencode/adapter.d.ts.map +1 -1
  68. package/dist/providers/opencode/adapter.js +13 -6
  69. package/dist/providers/opencode/adapter.js.map +1 -1
  70. package/dist/providers/opencode/hooks.d.ts +89 -28
  71. package/dist/providers/opencode/hooks.d.ts.map +1 -1
  72. package/dist/providers/opencode/hooks.js +145 -37
  73. package/dist/providers/opencode/hooks.js.map +1 -1
  74. package/package.json +3 -2
  75. package/src/index.ts +18 -0
  76. package/src/providers/claude-code/adapter.ts +16 -5
  77. package/src/providers/claude-code/hooks.ts +154 -30
  78. package/src/providers/codex/adapter.ts +154 -0
  79. package/src/providers/codex/hooks.ts +163 -0
  80. package/src/providers/codex/index.ts +27 -0
  81. package/src/providers/codex/install.ts +203 -0
  82. package/src/providers/codex/manifest.json +28 -0
  83. package/src/providers/cursor/adapter.ts +16 -2
  84. package/src/providers/cursor/hooks.ts +167 -18
  85. package/src/providers/gemini-cli/adapter.ts +165 -0
  86. package/src/providers/gemini-cli/hooks.ts +177 -0
  87. package/src/providers/gemini-cli/index.ts +27 -0
  88. package/src/providers/gemini-cli/install.ts +203 -0
  89. package/src/providers/gemini-cli/manifest.json +35 -0
  90. package/src/providers/kimi/adapter.ts +153 -0
  91. package/src/providers/kimi/hooks.ts +80 -0
  92. package/src/providers/kimi/index.ts +27 -0
  93. package/src/providers/kimi/install.ts +209 -0
  94. package/src/providers/kimi/manifest.json +24 -0
  95. package/src/providers/opencode/adapter.ts +13 -6
  96. package/src/providers/opencode/hooks.ts +146 -37
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Codex CLI Adapter
3
+ *
4
+ * Main CLEOProviderAdapter implementation for OpenAI Codex CLI.
5
+ * Provides hooks and install capabilities for CLEO integration.
6
+ *
7
+ * @task T162
8
+ * @epic T134
9
+ */
10
+
11
+ import { exec } from 'node:child_process';
12
+ import { existsSync } from 'node:fs';
13
+ import { homedir } from 'node:os';
14
+ import { join } from 'node:path';
15
+ import { promisify } from 'node:util';
16
+ import type {
17
+ AdapterCapabilities,
18
+ AdapterHealthStatus,
19
+ CLEOProviderAdapter,
20
+ } from '@cleocode/contracts';
21
+ import { CodexHookProvider } from './hooks.js';
22
+ import { CodexInstallProvider } from './install.js';
23
+
24
+ const execAsync = promisify(exec);
25
+
26
+ /**
27
+ * CLEO provider adapter for OpenAI Codex CLI.
28
+ *
29
+ * Bridges CLEO's adapter system with Codex CLI's native capabilities:
30
+ * - Hooks: Maps Codex events (SessionStart, PromptSubmit, ResponseComplete) to CAAMP events
31
+ * - Install: Registers MCP server in ~/.codex/config.json and ensures AGENTS.md references
32
+ *
33
+ * @task T162
34
+ * @epic T134
35
+ */
36
+ export class CodexAdapter implements CLEOProviderAdapter {
37
+ readonly id = 'codex';
38
+ readonly name = 'Codex';
39
+ readonly version = '1.0.0';
40
+
41
+ capabilities: AdapterCapabilities = {
42
+ supportsHooks: true,
43
+ supportedHookEvents: ['SessionStart', 'UserPromptSubmit', 'Stop'],
44
+ supportsSpawn: false,
45
+ supportsInstall: true,
46
+ supportsMcp: true,
47
+ supportsInstructionFiles: false,
48
+ supportsContextMonitor: false,
49
+ supportsStatusline: false,
50
+ supportsProviderPaths: false,
51
+ supportsTransport: false,
52
+ supportsTaskSync: false,
53
+ };
54
+
55
+ hooks: CodexHookProvider;
56
+ install: CodexInstallProvider;
57
+
58
+ private projectDir: string | null = null;
59
+ private initialized = false;
60
+
61
+ constructor() {
62
+ this.hooks = new CodexHookProvider();
63
+ this.install = new CodexInstallProvider();
64
+ }
65
+
66
+ /**
67
+ * Initialize the adapter for a given project directory.
68
+ *
69
+ * @param projectDir - Root directory of the project
70
+ * @task T162
71
+ */
72
+ async initialize(projectDir: string): Promise<void> {
73
+ this.projectDir = projectDir;
74
+ this.initialized = true;
75
+ }
76
+
77
+ /**
78
+ * Dispose the adapter and clean up resources.
79
+ *
80
+ * Unregisters hooks and releases any tracked state.
81
+ * @task T162
82
+ */
83
+ async dispose(): Promise<void> {
84
+ if (this.hooks.isRegistered()) {
85
+ await this.hooks.unregisterNativeHooks();
86
+ }
87
+ this.initialized = false;
88
+ this.projectDir = null;
89
+ }
90
+
91
+ /**
92
+ * Run a health check to verify Codex CLI is accessible.
93
+ *
94
+ * Checks:
95
+ * 1. Adapter has been initialized
96
+ * 2. Codex CLI binary is available in PATH
97
+ * 3. ~/.codex/ configuration directory exists
98
+ *
99
+ * @returns Health status with details about each check
100
+ * @task T162
101
+ */
102
+ async healthCheck(): Promise<AdapterHealthStatus> {
103
+ const details: Record<string, unknown> = {};
104
+
105
+ if (!this.initialized) {
106
+ return {
107
+ healthy: false,
108
+ provider: this.id,
109
+ details: { error: 'Adapter not initialized' },
110
+ };
111
+ }
112
+
113
+ // Check Codex CLI availability
114
+ let cliAvailable = false;
115
+ try {
116
+ const { stdout } = await execAsync('which codex');
117
+ cliAvailable = stdout.trim().length > 0;
118
+ details.cliPath = stdout.trim();
119
+ } catch {
120
+ details.cliAvailable = false;
121
+ }
122
+
123
+ // Check for Codex CLI config directory
124
+ const codexConfigDir = join(homedir(), '.codex');
125
+ const configExists = existsSync(codexConfigDir);
126
+ details.configDirExists = configExists;
127
+
128
+ // Healthy if CLI is available (primary requirement)
129
+ const healthy = cliAvailable;
130
+ details.cliAvailable = cliAvailable;
131
+
132
+ return {
133
+ healthy,
134
+ provider: this.id,
135
+ details,
136
+ };
137
+ }
138
+
139
+ /**
140
+ * Check whether the adapter has been initialized.
141
+ * @task T162
142
+ */
143
+ isInitialized(): boolean {
144
+ return this.initialized;
145
+ }
146
+
147
+ /**
148
+ * Get the project directory this adapter was initialized with.
149
+ * @task T162
150
+ */
151
+ getProjectDir(): string | null {
152
+ return this.projectDir;
153
+ }
154
+ }
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Codex CLI Hook Provider
3
+ *
4
+ * Maps Codex CLI's native hook events to CAAMP canonical hook events.
5
+ * Codex CLI supports 3 canonical events through its hook system.
6
+ *
7
+ * Codex CLI event mapping:
8
+ * - SessionStart -> SessionStart
9
+ * - PromptSubmit -> UserPromptSubmit
10
+ * - ResponseComplete -> Stop
11
+ *
12
+ * @task T162
13
+ * @epic T134
14
+ */
15
+
16
+ import { readdir, readFile } from 'node:fs/promises';
17
+ import { join } from 'node:path';
18
+ import type { AdapterHookProvider } from '@cleocode/contracts';
19
+
20
+ /**
21
+ * Mapping from Codex CLI native event names to CAAMP canonical event names.
22
+ */
23
+ const CODEX_EVENT_MAP: Record<string, string> = {
24
+ SessionStart: 'SessionStart',
25
+ PromptSubmit: 'UserPromptSubmit',
26
+ ResponseComplete: 'Stop',
27
+ };
28
+
29
+ /**
30
+ * Hook provider for Codex CLI.
31
+ *
32
+ * Codex CLI registers hooks via its configuration system at
33
+ * ~/.codex/. Hook handlers are shell commands or script paths that
34
+ * execute when the corresponding event fires.
35
+ *
36
+ * Since hooks are registered through the config system (managed by
37
+ * the install provider), registerNativeHooks and unregisterNativeHooks
38
+ * track registration state without performing filesystem operations.
39
+ *
40
+ * @task T162
41
+ * @epic T134
42
+ */
43
+ export class CodexHookProvider implements AdapterHookProvider {
44
+ private registered = false;
45
+
46
+ /**
47
+ * Map a Codex CLI native event name to a CAAMP hook event name.
48
+ *
49
+ * @param providerEvent - Codex CLI event name (e.g. "SessionStart", "PromptSubmit")
50
+ * @returns CAAMP event name or null if unmapped
51
+ * @task T162
52
+ */
53
+ mapProviderEvent(providerEvent: string): string | null {
54
+ return CODEX_EVENT_MAP[providerEvent] ?? null;
55
+ }
56
+
57
+ /**
58
+ * Register native hooks for a project.
59
+ *
60
+ * For Codex CLI, hooks are registered via the config system
61
+ * (~/.codex/), which is handled by the install provider.
62
+ * This method marks hooks as registered without performing
63
+ * filesystem operations.
64
+ *
65
+ * @param _projectDir - Project directory (unused; hooks are global)
66
+ * @task T162
67
+ */
68
+ async registerNativeHooks(_projectDir: string): Promise<void> {
69
+ this.registered = true;
70
+ }
71
+
72
+ /**
73
+ * Unregister native hooks.
74
+ *
75
+ * For Codex CLI, this is a no-op since hooks are managed through
76
+ * the config system. Unregistration happens via the install
77
+ * provider's uninstall method.
78
+ * @task T162
79
+ */
80
+ async unregisterNativeHooks(): Promise<void> {
81
+ this.registered = false;
82
+ }
83
+
84
+ /**
85
+ * Check whether hooks have been registered via registerNativeHooks.
86
+ * @task T162
87
+ */
88
+ isRegistered(): boolean {
89
+ return this.registered;
90
+ }
91
+
92
+ /**
93
+ * Get the full event mapping for introspection/debugging.
94
+ * @task T162
95
+ */
96
+ getEventMap(): Readonly<Record<string, string>> {
97
+ return { ...CODEX_EVENT_MAP };
98
+ }
99
+
100
+ /**
101
+ * Extract a plain-text transcript from Codex CLI session data.
102
+ *
103
+ * Reads the most recent session file under ~/.codex/ and extracts
104
+ * turn text into a flat string for brain observation extraction.
105
+ *
106
+ * Returns null when no session data is found or on any read error.
107
+ *
108
+ * @param _sessionId - CLEO session ID (unused; reads the most recent file)
109
+ * @param _projectDir - Project directory (unused; Codex CLI uses global paths)
110
+ * @task T162 @epic T134
111
+ */
112
+ async getTranscript(_sessionId: string, _projectDir: string): Promise<string | null> {
113
+ try {
114
+ const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? '/root';
115
+ const codexDir = join(homeDir, '.codex');
116
+
117
+ let allFiles: string[] = [];
118
+ try {
119
+ const entries = await readdir(codexDir, { withFileTypes: true });
120
+ for (const entry of entries) {
121
+ if (!entry.isFile()) continue;
122
+ const name = entry.name;
123
+ if (name.endsWith('.json') || name.endsWith('.jsonl')) {
124
+ allFiles.push(join(codexDir, name));
125
+ }
126
+ }
127
+ } catch {
128
+ return null;
129
+ }
130
+
131
+ if (allFiles.length === 0) return null;
132
+
133
+ // Sort descending by filename (timestamps in filenames sort naturally)
134
+ allFiles = allFiles.sort((a, b) => b.localeCompare(a));
135
+ const mostRecent = allFiles[0];
136
+ if (!mostRecent) return null;
137
+
138
+ const raw = await readFile(mostRecent, 'utf-8');
139
+ const turns: string[] = [];
140
+
141
+ // Support both JSONL (one JSON per line) and JSON array formats
142
+ const lines = raw.split('\n').filter((l) => l.trim());
143
+ for (const line of lines) {
144
+ try {
145
+ const entry = JSON.parse(line) as Record<string, unknown>;
146
+ const role = entry.role as string | undefined;
147
+ const content = entry.content;
148
+ if (role === 'assistant' && typeof content === 'string') {
149
+ turns.push(`assistant: ${content}`);
150
+ } else if (role === 'user' && typeof content === 'string') {
151
+ turns.push(`user: ${content}`);
152
+ }
153
+ } catch {
154
+ // Skip malformed lines
155
+ }
156
+ }
157
+
158
+ return turns.length > 0 ? turns.join('\n') : null;
159
+ } catch {
160
+ return null;
161
+ }
162
+ }
163
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Codex CLI provider adapter.
3
+ *
4
+ * CLEO provider adapter for OpenAI Codex CLI.
5
+ * Default export is the adapter class for dynamic loading by AdapterManager.
6
+ *
7
+ * @task T162
8
+ * @epic T134
9
+ */
10
+
11
+ import { CodexAdapter } from './adapter.js';
12
+
13
+ export { CodexAdapter } from './adapter.js';
14
+ export { CodexHookProvider } from './hooks.js';
15
+ export { CodexInstallProvider } from './install.js';
16
+
17
+ export default CodexAdapter;
18
+
19
+ /**
20
+ * Factory function for creating adapter instances.
21
+ * Used by AdapterManager's dynamic import fallback.
22
+ *
23
+ * @task T162
24
+ */
25
+ export function createAdapter(): CodexAdapter {
26
+ return new CodexAdapter();
27
+ }
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Codex CLI Install Provider
3
+ *
4
+ * Handles CLEO installation into Codex CLI environments:
5
+ * - Registers CLEO MCP server in ~/.codex/config.json
6
+ * - Ensures AGENTS.md has CLEO @-references
7
+ *
8
+ * @task T162
9
+ * @epic T134
10
+ */
11
+
12
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
13
+ import { homedir } from 'node:os';
14
+ import { join } from 'node:path';
15
+ import type { AdapterInstallProvider, InstallOptions, InstallResult } from '@cleocode/contracts';
16
+
17
+ /** Lines that should appear in AGENTS.md to reference CLEO. */
18
+ const INSTRUCTION_REFERENCES = ['@~/.cleo/templates/CLEO-INJECTION.md', '@.cleo/memory-bridge.md'];
19
+
20
+ /** MCP server registration key used in Codex CLI config. */
21
+ const MCP_SERVER_KEY = 'cleo';
22
+
23
+ /**
24
+ * Install provider for Codex CLI.
25
+ *
26
+ * Manages CLEO's integration with Codex CLI by:
27
+ * 1. Registering the CLEO MCP server in ~/.codex/config.json
28
+ * 2. Ensuring AGENTS.md contains @-references to CLEO instruction files
29
+ *
30
+ * @task T162
31
+ * @epic T134
32
+ */
33
+ export class CodexInstallProvider implements AdapterInstallProvider {
34
+ /**
35
+ * Install CLEO into a Codex CLI environment.
36
+ *
37
+ * @param options - Installation options including project directory and MCP server path
38
+ * @returns Result describing what was installed
39
+ * @task T162
40
+ */
41
+ async install(options: InstallOptions): Promise<InstallResult> {
42
+ const { projectDir, mcpServerPath } = options;
43
+ const installedAt = new Date().toISOString();
44
+ let instructionFileUpdated = false;
45
+ let mcpRegistered = false;
46
+ const details: Record<string, unknown> = {};
47
+
48
+ // Step 1: Register MCP server in ~/.codex/config.json
49
+ if (mcpServerPath) {
50
+ mcpRegistered = this.registerMcpServer(mcpServerPath);
51
+ if (mcpRegistered) {
52
+ details.mcpConfigPath = join(homedir(), '.codex', 'config.json');
53
+ }
54
+ }
55
+
56
+ // Step 2: Ensure AGENTS.md has @-references
57
+ instructionFileUpdated = this.updateInstructionFile(projectDir);
58
+ if (instructionFileUpdated) {
59
+ details.instructionFile = join(projectDir, 'AGENTS.md');
60
+ }
61
+
62
+ return {
63
+ success: true,
64
+ installedAt,
65
+ instructionFileUpdated,
66
+ mcpRegistered,
67
+ details,
68
+ };
69
+ }
70
+
71
+ /**
72
+ * Uninstall CLEO from the Codex CLI environment.
73
+ *
74
+ * Removes the MCP server registration from ~/.codex/config.json.
75
+ * Does not remove AGENTS.md references (they are harmless if CLEO is not present).
76
+ * @task T162
77
+ */
78
+ async uninstall(): Promise<void> {
79
+ const configPath = join(homedir(), '.codex', 'config.json');
80
+ if (existsSync(configPath)) {
81
+ try {
82
+ const raw = readFileSync(configPath, 'utf-8');
83
+ const config = JSON.parse(raw) as Record<string, unknown>;
84
+ const mcpServers = config.mcpServers as Record<string, unknown> | undefined;
85
+ if (mcpServers && MCP_SERVER_KEY in mcpServers) {
86
+ delete mcpServers[MCP_SERVER_KEY];
87
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
88
+ }
89
+ } catch {
90
+ // Ignore errors during uninstall
91
+ }
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Check whether CLEO is installed in the Codex CLI environment.
97
+ *
98
+ * Checks for MCP server registered in ~/.codex/config.json.
99
+ * Returns true if the CLEO MCP server entry is found.
100
+ * @task T162
101
+ */
102
+ async isInstalled(): Promise<boolean> {
103
+ const configPath = join(homedir(), '.codex', 'config.json');
104
+ if (existsSync(configPath)) {
105
+ try {
106
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'));
107
+ const mcpServers = config.mcpServers as Record<string, unknown> | undefined;
108
+ if (mcpServers && MCP_SERVER_KEY in mcpServers) {
109
+ return true;
110
+ }
111
+ } catch {
112
+ // Fall through
113
+ }
114
+ }
115
+
116
+ return false;
117
+ }
118
+
119
+ /**
120
+ * Ensure AGENTS.md contains @-references to CLEO instruction files.
121
+ *
122
+ * Creates AGENTS.md if it does not exist. Appends any missing references.
123
+ *
124
+ * @param projectDir - Project root directory
125
+ * @task T162
126
+ */
127
+ async ensureInstructionReferences(projectDir: string): Promise<void> {
128
+ this.updateInstructionFile(projectDir);
129
+ }
130
+
131
+ /**
132
+ * Register the CLEO MCP server in ~/.codex/config.json.
133
+ *
134
+ * Codex CLI stores its MCP server configuration in ~/.codex/config.json
135
+ * under the mcpServers key.
136
+ *
137
+ * @param mcpServerPath - Absolute path to the MCP server entry point
138
+ * @returns true if registration was performed or updated
139
+ */
140
+ private registerMcpServer(mcpServerPath: string): boolean {
141
+ const codexDir = join(homedir(), '.codex');
142
+ const configPath = join(codexDir, 'config.json');
143
+ let config: Record<string, unknown> = {};
144
+
145
+ mkdirSync(codexDir, { recursive: true });
146
+
147
+ if (existsSync(configPath)) {
148
+ try {
149
+ config = JSON.parse(readFileSync(configPath, 'utf-8'));
150
+ } catch {
151
+ // Start fresh on parse error
152
+ }
153
+ }
154
+
155
+ if (!config.mcpServers || typeof config.mcpServers !== 'object') {
156
+ config.mcpServers = {};
157
+ }
158
+
159
+ const mcpServers = config.mcpServers as Record<string, unknown>;
160
+ mcpServers[MCP_SERVER_KEY] = {
161
+ command: 'node',
162
+ args: [mcpServerPath],
163
+ };
164
+
165
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
166
+ return true;
167
+ }
168
+
169
+ /**
170
+ * Update AGENTS.md with CLEO @-references.
171
+ *
172
+ * @param projectDir - Project root directory
173
+ * @returns true if the file was created or modified
174
+ */
175
+ private updateInstructionFile(projectDir: string): boolean {
176
+ const agentsMdPath = join(projectDir, 'AGENTS.md');
177
+ let content = '';
178
+ let existed = false;
179
+
180
+ if (existsSync(agentsMdPath)) {
181
+ content = readFileSync(agentsMdPath, 'utf-8');
182
+ existed = true;
183
+ }
184
+
185
+ const missingRefs = INSTRUCTION_REFERENCES.filter((ref) => !content.includes(ref));
186
+
187
+ if (missingRefs.length === 0) {
188
+ return false;
189
+ }
190
+
191
+ const refsBlock = missingRefs.join('\n');
192
+
193
+ if (existed) {
194
+ const separator = content.endsWith('\n') ? '' : '\n';
195
+ content = content + separator + refsBlock + '\n';
196
+ } else {
197
+ content = refsBlock + '\n';
198
+ }
199
+
200
+ writeFileSync(agentsMdPath, content, 'utf-8');
201
+ return true;
202
+ }
203
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "id": "codex",
3
+ "name": "Codex Adapter",
4
+ "version": "1.0.0",
5
+ "description": "CLEO adapter for OpenAI Codex CLI",
6
+ "provider": "codex",
7
+ "entryPoint": "src/index.ts",
8
+ "capabilities": {
9
+ "supportsHooks": true,
10
+ "supportedHookEvents": [
11
+ "SessionStart",
12
+ "UserPromptSubmit",
13
+ "Stop"
14
+ ],
15
+ "supportsSpawn": false,
16
+ "supportsInstall": true,
17
+ "supportsMcp": true,
18
+ "supportsInstructionFiles": false,
19
+ "supportsContextMonitor": false,
20
+ "supportsStatusline": false,
21
+ "supportsProviderPaths": false,
22
+ "supportsTransport": false
23
+ },
24
+ "detectionPatterns": [
25
+ { "type": "cli", "pattern": "codex", "description": "Codex CLI binary available in PATH" },
26
+ { "type": "directory", "pattern": "~/.codex", "description": "Codex CLI config directory" }
27
+ ]
28
+ }
@@ -33,8 +33,22 @@ export class CursorAdapter implements CLEOProviderAdapter {
33
33
  readonly version = '1.0.0';
34
34
 
35
35
  capabilities: AdapterCapabilities = {
36
- supportsHooks: false,
37
- supportedHookEvents: [],
36
+ supportsHooks: true,
37
+ // 10/16 canonical events — derived from getProviderHookProfile('cursor') in CAAMP 1.9.1.
38
+ // PermissionRequest, PreModel, PostModel, PostCompact, Notification, ConfigChange are
39
+ // not supported by Cursor's hook system.
40
+ supportedHookEvents: [
41
+ 'SessionStart',
42
+ 'SessionEnd',
43
+ 'PromptSubmit',
44
+ 'ResponseComplete',
45
+ 'PreToolUse',
46
+ 'PostToolUse',
47
+ 'PostToolUseFailure',
48
+ 'SubagentStart',
49
+ 'SubagentStop',
50
+ 'PreCompact',
51
+ ],
38
52
  supportsSpawn: false,
39
53
  supportsInstall: true,
40
54
  supportsMcp: true,