@cleocode/adapters 2026.4.58 → 2026.4.59

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 (109) hide show
  1. package/dist/cant-context.js +711 -0
  2. package/dist/cant-context.js.map +1 -0
  3. package/dist/providers/claude-code/adapter.js +222 -0
  4. package/dist/providers/claude-code/adapter.js.map +1 -0
  5. package/dist/providers/claude-code/context-monitor.js +159 -0
  6. package/dist/providers/claude-code/context-monitor.js.map +1 -0
  7. package/dist/providers/claude-code/hooks.js +395 -0
  8. package/dist/providers/claude-code/hooks.js.map +1 -0
  9. package/dist/providers/claude-code/index.js +41 -0
  10. package/dist/providers/claude-code/index.js.map +1 -0
  11. package/dist/providers/claude-code/install.js +199 -0
  12. package/dist/providers/claude-code/install.js.map +1 -0
  13. package/dist/providers/claude-code/paths.js +41 -0
  14. package/dist/providers/claude-code/paths.js.map +1 -0
  15. package/dist/providers/claude-code/spawn.js +198 -0
  16. package/dist/providers/claude-code/spawn.js.map +1 -0
  17. package/dist/providers/claude-code/statusline.js +130 -0
  18. package/dist/providers/claude-code/statusline.js.map +1 -0
  19. package/dist/providers/claude-code/task-sync.js +119 -0
  20. package/dist/providers/claude-code/task-sync.js.map +1 -0
  21. package/dist/providers/claude-code/transport.js +29 -0
  22. package/dist/providers/claude-code/transport.js.map +1 -0
  23. package/dist/providers/claude-sdk/index.js +16 -0
  24. package/dist/providers/claude-sdk/index.js.map +1 -0
  25. package/dist/providers/claude-sdk/mcp-registry.js +66 -0
  26. package/dist/providers/claude-sdk/mcp-registry.js.map +1 -0
  27. package/dist/providers/claude-sdk/session-store.js +84 -0
  28. package/dist/providers/claude-sdk/session-store.js.map +1 -0
  29. package/dist/providers/claude-sdk/spawn.js +225 -0
  30. package/dist/providers/claude-sdk/spawn.js.map +1 -0
  31. package/dist/providers/claude-sdk/tool-bridge.js +50 -0
  32. package/dist/providers/claude-sdk/tool-bridge.js.map +1 -0
  33. package/dist/providers/codex/adapter.js +146 -0
  34. package/dist/providers/codex/adapter.js.map +1 -0
  35. package/dist/providers/codex/hooks.js +113 -0
  36. package/dist/providers/codex/hooks.js.map +1 -0
  37. package/dist/providers/codex/index.js +39 -0
  38. package/dist/providers/codex/index.js.map +1 -0
  39. package/dist/providers/codex/install.js +124 -0
  40. package/dist/providers/codex/install.js.map +1 -0
  41. package/dist/providers/cursor/adapter.js +151 -0
  42. package/dist/providers/cursor/adapter.js.map +1 -0
  43. package/dist/providers/cursor/hooks.js +208 -0
  44. package/dist/providers/cursor/hooks.js.map +1 -0
  45. package/dist/providers/cursor/index.js +36 -0
  46. package/dist/providers/cursor/index.js.map +1 -0
  47. package/dist/providers/cursor/install.js +180 -0
  48. package/dist/providers/cursor/install.js.map +1 -0
  49. package/dist/providers/cursor/spawn.js +59 -0
  50. package/dist/providers/cursor/spawn.js.map +1 -0
  51. package/dist/providers/gemini-cli/adapter.js +158 -0
  52. package/dist/providers/gemini-cli/adapter.js.map +1 -0
  53. package/dist/providers/gemini-cli/hooks.js +128 -0
  54. package/dist/providers/gemini-cli/hooks.js.map +1 -0
  55. package/dist/providers/gemini-cli/index.js +39 -0
  56. package/dist/providers/gemini-cli/index.js.map +1 -0
  57. package/dist/providers/gemini-cli/install.js +124 -0
  58. package/dist/providers/gemini-cli/install.js.map +1 -0
  59. package/dist/providers/kimi/adapter.js +145 -0
  60. package/dist/providers/kimi/adapter.js.map +1 -0
  61. package/dist/providers/kimi/hooks.js +79 -0
  62. package/dist/providers/kimi/hooks.js.map +1 -0
  63. package/dist/providers/kimi/index.js +39 -0
  64. package/dist/providers/kimi/index.js.map +1 -0
  65. package/dist/providers/kimi/install.js +124 -0
  66. package/dist/providers/kimi/install.js.map +1 -0
  67. package/dist/providers/openai-sdk/adapter.js +120 -0
  68. package/dist/providers/openai-sdk/adapter.js.map +1 -0
  69. package/dist/providers/openai-sdk/guardrails.js +139 -0
  70. package/dist/providers/openai-sdk/guardrails.js.map +1 -0
  71. package/dist/providers/openai-sdk/handoff.js +124 -0
  72. package/dist/providers/openai-sdk/handoff.js.map +1 -0
  73. package/dist/providers/openai-sdk/index.js +39 -0
  74. package/dist/providers/openai-sdk/index.js.map +1 -0
  75. package/dist/providers/openai-sdk/install.js +120 -0
  76. package/dist/providers/openai-sdk/install.js.map +1 -0
  77. package/dist/providers/openai-sdk/spawn.js +214 -0
  78. package/dist/providers/openai-sdk/spawn.js.map +1 -0
  79. package/dist/providers/openai-sdk/tracing.js +157 -0
  80. package/dist/providers/openai-sdk/tracing.js.map +1 -0
  81. package/dist/providers/opencode/adapter.js +166 -0
  82. package/dist/providers/opencode/adapter.js.map +1 -0
  83. package/dist/providers/opencode/hooks.js +206 -0
  84. package/dist/providers/opencode/hooks.js.map +1 -0
  85. package/dist/providers/opencode/index.js +37 -0
  86. package/dist/providers/opencode/index.js.map +1 -0
  87. package/dist/providers/opencode/install.js +115 -0
  88. package/dist/providers/opencode/install.js.map +1 -0
  89. package/dist/providers/opencode/spawn.js +256 -0
  90. package/dist/providers/opencode/spawn.js.map +1 -0
  91. package/dist/providers/pi/adapter.js +220 -0
  92. package/dist/providers/pi/adapter.js.map +1 -0
  93. package/dist/providers/pi/hooks.js +223 -0
  94. package/dist/providers/pi/hooks.js.map +1 -0
  95. package/dist/providers/pi/index.js +38 -0
  96. package/dist/providers/pi/index.js.map +1 -0
  97. package/dist/providers/pi/install.js +175 -0
  98. package/dist/providers/pi/install.js.map +1 -0
  99. package/dist/providers/pi/spawn.js +187 -0
  100. package/dist/providers/pi/spawn.js.map +1 -0
  101. package/dist/providers/shared/conduit-trace-writer.js +65 -0
  102. package/dist/providers/shared/conduit-trace-writer.js.map +1 -0
  103. package/dist/providers/shared/sdk-result-mapper.js +54 -0
  104. package/dist/providers/shared/sdk-result-mapper.js.map +1 -0
  105. package/dist/providers/shared/transcript-reader.js +124 -0
  106. package/dist/providers/shared/transcript-reader.js.map +1 -0
  107. package/dist/registry.js +92 -0
  108. package/dist/registry.js.map +1 -0
  109. package/package.json +3 -3
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @packageDocumentation
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
+ import { CodexAdapter } from './adapter.js';
11
+ export { CodexAdapter } from './adapter.js';
12
+ export { CodexHookProvider } from './hooks.js';
13
+ export { CodexInstallProvider } from './install.js';
14
+ export default CodexAdapter;
15
+ /**
16
+ * Factory function for creating adapter instances.
17
+ * Used by AdapterManager's dynamic import fallback.
18
+ *
19
+ * @remarks
20
+ * This is the primary entry point for dynamic adapter loading.
21
+ * AdapterManager calls this function when it resolves the codex
22
+ * provider via its import-based discovery mechanism.
23
+ *
24
+ * @returns A new {@link CodexAdapter} instance ready for initialization
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { createAdapter } from '@cleocode/adapters/providers/codex';
29
+ *
30
+ * const adapter = createAdapter();
31
+ * await adapter.initialize('/path/to/project');
32
+ * ```
33
+ *
34
+ * @task T162
35
+ */
36
+ export function createAdapter() {
37
+ return new CodexAdapter();
38
+ }
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/codex/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAe,YAAY,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,YAAY,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Codex CLI Install Provider
3
+ *
4
+ * Handles CLEO installation into Codex CLI environments:
5
+ * - Ensures AGENTS.md has CLEO @-references
6
+ *
7
+ * @task T162
8
+ * @epic T134
9
+ */
10
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
11
+ import { join } from 'node:path';
12
+ /** Lines that should appear in AGENTS.md to reference CLEO. */
13
+ const INSTRUCTION_REFERENCES = ['@~/.cleo/templates/CLEO-INJECTION.md', '@.cleo/memory-bridge.md'];
14
+ /**
15
+ * Install provider for Codex CLI.
16
+ *
17
+ * Manages CLEO's integration with Codex CLI by:
18
+ * 1. Ensuring AGENTS.md contains @-references to CLEO instruction files
19
+ *
20
+ * @remarks
21
+ * Installation is idempotent -- running install multiple times on the same
22
+ * project produces the same result. Only AGENTS.md is managed; Codex CLI
23
+ * does not have an MCP or plugin registration mechanism.
24
+ *
25
+ * @task T162
26
+ * @epic T134
27
+ */
28
+ export class CodexInstallProvider {
29
+ /**
30
+ * Install CLEO into a Codex CLI environment.
31
+ *
32
+ * @param options - Installation options including project directory
33
+ * @returns Result describing what was installed
34
+ * @task T162
35
+ */
36
+ async install(options) {
37
+ const { projectDir } = options;
38
+ const installedAt = new Date().toISOString();
39
+ let instructionFileUpdated = false;
40
+ const details = {};
41
+ // Step 1: Ensure AGENTS.md has @-references
42
+ instructionFileUpdated = this.updateInstructionFile(projectDir);
43
+ if (instructionFileUpdated) {
44
+ details.instructionFile = join(projectDir, 'AGENTS.md');
45
+ }
46
+ return {
47
+ success: true,
48
+ installedAt,
49
+ instructionFileUpdated,
50
+ details,
51
+ };
52
+ }
53
+ /**
54
+ * Uninstall CLEO from the Codex CLI environment.
55
+ *
56
+ * Does not remove AGENTS.md references (they are harmless if CLEO is not present).
57
+ * @task T162
58
+ */
59
+ async uninstall() {
60
+ // No-op: no MCP registration to remove
61
+ }
62
+ /**
63
+ * Check whether CLEO is installed in the Codex CLI environment.
64
+ *
65
+ * Checks for CLEO references in AGENTS.md.
66
+ * @task T162
67
+ */
68
+ async isInstalled() {
69
+ const agentsMdPath = join(process.cwd(), 'AGENTS.md');
70
+ if (existsSync(agentsMdPath)) {
71
+ try {
72
+ const content = readFileSync(agentsMdPath, 'utf-8');
73
+ if (INSTRUCTION_REFERENCES.some((ref) => content.includes(ref))) {
74
+ return true;
75
+ }
76
+ }
77
+ catch {
78
+ // Fall through
79
+ }
80
+ }
81
+ return false;
82
+ }
83
+ /**
84
+ * Ensure AGENTS.md contains @-references to CLEO instruction files.
85
+ *
86
+ * Creates AGENTS.md if it does not exist. Appends any missing references.
87
+ *
88
+ * @param projectDir - Project root directory
89
+ * @task T162
90
+ */
91
+ async ensureInstructionReferences(projectDir) {
92
+ this.updateInstructionFile(projectDir);
93
+ }
94
+ /**
95
+ * Update AGENTS.md with CLEO @-references.
96
+ *
97
+ * @param projectDir - Project root directory
98
+ * @returns true if the file was created or modified
99
+ */
100
+ updateInstructionFile(projectDir) {
101
+ const agentsMdPath = join(projectDir, 'AGENTS.md');
102
+ let content = '';
103
+ let existed = false;
104
+ if (existsSync(agentsMdPath)) {
105
+ content = readFileSync(agentsMdPath, 'utf-8');
106
+ existed = true;
107
+ }
108
+ const missingRefs = INSTRUCTION_REFERENCES.filter((ref) => !content.includes(ref));
109
+ if (missingRefs.length === 0) {
110
+ return false;
111
+ }
112
+ const refsBlock = missingRefs.join('\n');
113
+ if (existed) {
114
+ const separator = content.endsWith('\n') ? '' : '\n';
115
+ content = content + separator + refsBlock + '\n';
116
+ }
117
+ else {
118
+ content = refsBlock + '\n';
119
+ }
120
+ writeFileSync(agentsMdPath, content, 'utf-8');
121
+ return true;
122
+ }
123
+ }
124
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/providers/codex/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WA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Main CLEOProviderAdapter implementation for Cursor AI code editor.
5
+ * Provides install capabilities for CLEO integration. Hooks and spawn
6
+ * are not supported since Cursor lacks CLI-based lifecycle events
7
+ * and subagent spawning.
8
+ *
9
+ * @task T5240
10
+ */
11
+ import { existsSync } from 'node:fs';
12
+ import { join } from 'node:path';
13
+ import { CursorHookProvider } from './hooks.js';
14
+ import { CursorInstallProvider } from './install.js';
15
+ /**
16
+ * CLEO provider adapter for Cursor AI code editor.
17
+ *
18
+ * Bridges CLEO's adapter system with Cursor's capabilities:
19
+ * - Install: Manages .cursorrules and .cursor/rules/cleo.mdc rule files
20
+ * - Hooks: Stub provider (Cursor has no lifecycle event system)
21
+ * - Spawn: Not supported (Cursor has no CLI for subagent spawning)
22
+ *
23
+ * @remarks
24
+ * Cursor is a GUI-based editor, so many CLI-oriented capabilities
25
+ * (spawn, transport, task sync, context monitor) are unsupported.
26
+ * Integration is primarily through instruction rule files placed in
27
+ * `.cursor/rules/` (modern MDC format) and `.cursorrules` (legacy).
28
+ */
29
+ export class CursorAdapter {
30
+ /** Unique provider identifier. */
31
+ id = 'cursor';
32
+ /** Human-readable provider name. */
33
+ name = 'Cursor';
34
+ /** Adapter version string. */
35
+ version = '1.0.0';
36
+ /** Declared capabilities for this provider. */
37
+ capabilities = {
38
+ supportsHooks: true,
39
+ // 10/16 canonical events — derived from getProviderHookProfile('cursor') in CAAMP 1.9.1.
40
+ // PermissionRequest, PreModel, PostModel, PostCompact, Notification, ConfigChange are
41
+ // not supported by Cursor's hook system.
42
+ supportedHookEvents: [
43
+ 'SessionStart',
44
+ 'SessionEnd',
45
+ 'PromptSubmit',
46
+ 'ResponseComplete',
47
+ 'PreToolUse',
48
+ 'PostToolUse',
49
+ 'PostToolUseFailure',
50
+ 'SubagentStart',
51
+ 'SubagentStop',
52
+ 'PreCompact',
53
+ ],
54
+ supportsSpawn: false,
55
+ supportsInstall: true,
56
+ supportsInstructionFiles: true,
57
+ instructionFilePattern: '.cursor/rules/*.mdc',
58
+ supportsContextMonitor: false,
59
+ supportsStatusline: false,
60
+ supportsProviderPaths: true,
61
+ supportsTransport: false,
62
+ supportsTaskSync: false,
63
+ };
64
+ /** Hook provider for CAAMP event mapping. */
65
+ hooks;
66
+ /** Install provider for managing rule files. */
67
+ install;
68
+ /** Project directory this adapter was initialized with, or null. */
69
+ projectDir = null;
70
+ /** Whether {@link initialize} has been called. */
71
+ initialized = false;
72
+ constructor() {
73
+ this.hooks = new CursorHookProvider();
74
+ this.install = new CursorInstallProvider();
75
+ }
76
+ /**
77
+ * Initialize the adapter for a given project directory.
78
+ *
79
+ * @param projectDir - Root directory of the project
80
+ */
81
+ async initialize(projectDir) {
82
+ this.projectDir = projectDir;
83
+ this.initialized = true;
84
+ }
85
+ /**
86
+ * Dispose the adapter and clean up resources.
87
+ */
88
+ async dispose() {
89
+ if (this.hooks.isRegistered()) {
90
+ await this.hooks.unregisterNativeHooks();
91
+ }
92
+ this.initialized = false;
93
+ this.projectDir = null;
94
+ }
95
+ /**
96
+ * Run a health check to verify Cursor is accessible.
97
+ *
98
+ * Checks:
99
+ * 1. Adapter has been initialized
100
+ * 2. .cursor/ configuration directory exists in the project
101
+ * 3. CURSOR_EDITOR env var is set
102
+ *
103
+ * @returns Health status with details about each check
104
+ */
105
+ async healthCheck() {
106
+ const details = {};
107
+ if (!this.initialized) {
108
+ return {
109
+ healthy: false,
110
+ provider: this.id,
111
+ details: { error: 'Adapter not initialized' },
112
+ };
113
+ }
114
+ // Check for Cursor config directory in the project
115
+ let configExists = false;
116
+ if (this.projectDir) {
117
+ const cursorConfigDir = join(this.projectDir, '.cursor');
118
+ configExists = existsSync(cursorConfigDir);
119
+ details.configDirExists = configExists;
120
+ }
121
+ // Check for CURSOR_EDITOR env var
122
+ const editorEnvSet = process.env.CURSOR_EDITOR !== undefined;
123
+ details.editorEnvSet = editorEnvSet;
124
+ // Check for legacy .cursorrules file
125
+ if (this.projectDir) {
126
+ const legacyRulesExist = existsSync(join(this.projectDir, '.cursorrules'));
127
+ details.legacyRulesExist = legacyRulesExist;
128
+ }
129
+ // Healthy if we detect Cursor presence (config dir or env var)
130
+ const healthy = configExists || editorEnvSet;
131
+ details.detected = healthy;
132
+ return {
133
+ healthy,
134
+ provider: this.id,
135
+ details,
136
+ };
137
+ }
138
+ /**
139
+ * Check whether the adapter has been initialized.
140
+ */
141
+ isInitialized() {
142
+ return this.initialized;
143
+ }
144
+ /**
145
+ * Get the project directory this adapter was initialized with.
146
+ */
147
+ getProjectDir() {
148
+ return this.projectDir;
149
+ }
150
+ }
151
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/providers/cursor/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAMjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,aAAa;IACxB,kCAAkC;IACzB,EAAE,GAAG,QAAQ,CAAC;IACvB,oCAAoC;IAC3B,IAAI,GAAG,QAAQ,CAAC;IACzB,8BAA8B;IACrB,OAAO,GAAG,OAAO,CAAC;IAE3B,+CAA+C;IAC/C,YAAY,GAAwB;QAClC,aAAa,EAAE,IAAI;QACnB,yFAAyF;QACzF,sFAAsF;QACtF,yCAAyC;QACzC,mBAAmB,EAAE;YACnB,cAAc;YACd,YAAY;YACZ,cAAc;YACd,kBAAkB;YAClB,YAAY;YACZ,aAAa;YACb,oBAAoB;YACpB,eAAe;YACf,cAAc;YACd,YAAY;SACb;QACD,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,IAAI;QACrB,wBAAwB,EAAE,IAAI;QAC9B,sBAAsB,EAAE,qBAAqB;QAC7C,sBAAsB,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AAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;YACzD,YAAY,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;YAC3C,OAAO,CAAC,eAAe,GAAG,YAAY,CAAC;QACzC,CAAC;QAED,kCAAkC;QAClC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC;QAC7D,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;QAEpC,qCAAqC;QACrC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,MAAM,gBAAgB,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;YAC3E,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC9C,CAAC;QAED,+DAA+D;QAC/D,MAAM,OAAO,GAAG,YAAY,IAAI,YAAY,CAAC;QAC7C,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC;QAE3B,OAAO;YACL,OAAO;YACP,QAAQ,EAAE,IAAI,CAAC,EAAE;YACjB,OAAO;SACR,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Cursor Hook Provider
3
+ *
4
+ * Maps Cursor's native hook events to CAAMP canonical hook events.
5
+ * Cursor supports 10 of 16 canonical events through its config-based hook system.
6
+ *
7
+ * Event translation uses CAAMP normalizer APIs:
8
+ * - `toCanonical(nativeName, 'cursor')` for runtime event name resolution
9
+ * - `getSupportedEvents('cursor')` to enumerate supported canonical events
10
+ * - `getProviderHookProfile('cursor')` for the full provider profile
11
+ *
12
+ * Cursor uses camelCase native event names (e.g. `sessionStart`, `preToolUse`).
13
+ * Hooks are configured via `.cursor/hooks.json`. Supported handler types:
14
+ * command, prompt.
15
+ *
16
+ * Unsupported events: PermissionRequest, PreModel, PostModel, PostCompact,
17
+ * Notification, ConfigChange.
18
+ *
19
+ * @task T165
20
+ * @epic T134
21
+ */
22
+ /** CAAMP provider identifier for Cursor. */
23
+ const PROVIDER_ID = 'cursor';
24
+ /**
25
+ * Fallback map from Cursor native event names to CAAMP canonical names.
26
+ *
27
+ * Derived from `getProviderHookProfile('cursor').mappings` in CAAMP 1.9.1.
28
+ * Covers all 10 supported events. PermissionRequest, PreModel, PostModel,
29
+ * PostCompact, Notification, and ConfigChange are not supported by Cursor.
30
+ *
31
+ * Cursor uses camelCase names while CAAMP canonical names are PascalCase.
32
+ */
33
+ const CURSOR_EVENT_MAP = {
34
+ // CAAMP: toNative('SessionStart', 'cursor') = 'sessionStart'
35
+ sessionStart: 'SessionStart',
36
+ // CAAMP: toNative('SessionEnd', 'cursor') = 'sessionEnd'
37
+ sessionEnd: 'SessionEnd',
38
+ // CAAMP: toNative('PromptSubmit', 'cursor') = 'beforeSubmitPrompt'
39
+ beforeSubmitPrompt: 'PromptSubmit',
40
+ // CAAMP: toNative('ResponseComplete', 'cursor') = 'stop'
41
+ stop: 'ResponseComplete',
42
+ // CAAMP: toNative('PreToolUse', 'cursor') = 'preToolUse'
43
+ preToolUse: 'PreToolUse',
44
+ // CAAMP: toNative('PostToolUse', 'cursor') = 'postToolUse'
45
+ postToolUse: 'PostToolUse',
46
+ // CAAMP: toNative('PostToolUseFailure', 'cursor') = 'postToolUseFailure'
47
+ postToolUseFailure: 'PostToolUseFailure',
48
+ // CAAMP: toNative('SubagentStart', 'cursor') = 'subagentStart'
49
+ subagentStart: 'SubagentStart',
50
+ // CAAMP: toNative('SubagentStop', 'cursor') = 'subagentStop'
51
+ subagentStop: 'SubagentStop',
52
+ // CAAMP: toNative('PreCompact', 'cursor') = 'preCompact'
53
+ preCompact: 'PreCompact',
54
+ };
55
+ /**
56
+ * Hook provider for Cursor.
57
+ *
58
+ * Cursor registers hooks via its config system at `.cursor/hooks.json`.
59
+ * Supported handler types: command, prompt.
60
+ *
61
+ * CAAMP 1.9.1 reveals Cursor supports 10 of 16 canonical events. Previously
62
+ * this provider was a no-op stub. It now provides full event mapping and CAAMP
63
+ * normalizer integration.
64
+ *
65
+ * Event mapping is based on `getProviderHookProfile('cursor')` from CAAMP 1.9.1.
66
+ * Async accessors (`getSupportedCanonicalEvents`, `getProviderProfile`) call
67
+ * CAAMP directly when available.
68
+ *
69
+ * Since hooks are registered through the config system (managed by the install
70
+ * provider), `registerNativeHooks` and `unregisterNativeHooks` track registration
71
+ * state without performing filesystem operations.
72
+ *
73
+ * @remarks
74
+ * This provider was originally a no-op stub. It now provides full event
75
+ * mapping for all 10 canonical events supported by Cursor, plus CAAMP
76
+ * normalizer integration via async accessors. Registration state is
77
+ * tracked in-memory because Cursor manages hooks through its own config.
78
+ *
79
+ * @task T165
80
+ * @epic T134
81
+ */
82
+ export class CursorHookProvider {
83
+ /** Whether hooks have been registered for the current session. */
84
+ registered = false;
85
+ /**
86
+ * Map a Cursor native event name to a CAAMP canonical hook event name.
87
+ *
88
+ * Looks up the native event name in the map derived from
89
+ * `getProviderHookProfile('cursor').mappings` (CAAMP 1.9.1). Cursor uses
90
+ * camelCase names (e.g. "preToolUse", "sessionStart").
91
+ *
92
+ * Returns null for unsupported events (PermissionRequest, PreModel,
93
+ * PostModel, PostCompact, Notification, ConfigChange).
94
+ *
95
+ * @param providerEvent - Cursor native event name (e.g. "preToolUse", "sessionStart")
96
+ * @returns CAAMP canonical event name, or null if unmapped
97
+ * @task T165
98
+ */
99
+ mapProviderEvent(providerEvent) {
100
+ return CURSOR_EVENT_MAP[providerEvent] ?? null;
101
+ }
102
+ /**
103
+ * Register native hooks for a project.
104
+ *
105
+ * For Cursor, hooks are registered via the config system
106
+ * (`.cursor/hooks.json`), managed by the install provider.
107
+ * This method marks hooks as registered without performing filesystem operations.
108
+ *
109
+ * Iterating supported events is handled at install time using
110
+ * `getSupportedCanonicalEvents()` to enumerate all 10 supported hooks.
111
+ *
112
+ * @param _projectDir - Project directory (unused; Cursor config manages registration)
113
+ * @task T165
114
+ */
115
+ async registerNativeHooks(_projectDir) {
116
+ this.registered = true;
117
+ }
118
+ /**
119
+ * Unregister native hooks.
120
+ *
121
+ * For Cursor, this is a no-op since hooks are managed through the config
122
+ * system. Unregistration happens via the install provider's uninstall method.
123
+ *
124
+ * @task T165
125
+ */
126
+ async unregisterNativeHooks() {
127
+ this.registered = false;
128
+ }
129
+ /**
130
+ * Check whether hooks have been registered via `registerNativeHooks`.
131
+ */
132
+ isRegistered() {
133
+ return this.registered;
134
+ }
135
+ /**
136
+ * Get the native→canonical event mapping for introspection and debugging.
137
+ *
138
+ * Returns the map derived from `getProviderHookProfile('cursor').mappings`
139
+ * (CAAMP 1.9.1). Use `getSupportedCanonicalEvents()` to enumerate canonical
140
+ * names via live CAAMP APIs.
141
+ *
142
+ * @returns Immutable record of native event name → canonical event name
143
+ */
144
+ getEventMap() {
145
+ return { ...CURSOR_EVENT_MAP };
146
+ }
147
+ /**
148
+ * Enumerate supported canonical events via CAAMP's `getSupportedEvents()`.
149
+ *
150
+ * Calls `getSupportedEvents('cursor')` from the CAAMP normalizer to get the
151
+ * authoritative list. Cursor supports 10 of 16 canonical events. Falls back
152
+ * to the values of the static event map when CAAMP is unavailable at runtime.
153
+ *
154
+ * @returns Array of CAAMP canonical event names supported by Cursor
155
+ * @task T165
156
+ */
157
+ async getSupportedCanonicalEvents() {
158
+ try {
159
+ const { getSupportedEvents } = await import('@cleocode/caamp');
160
+ return getSupportedEvents(PROVIDER_ID);
161
+ }
162
+ catch {
163
+ return [...new Set(Object.values(CURSOR_EVENT_MAP))];
164
+ }
165
+ }
166
+ /**
167
+ * Retrieve the full provider hook profile from CAAMP.
168
+ *
169
+ * Calls `getProviderHookProfile('cursor')` from the CAAMP normalizer to
170
+ * get the complete profile: hook system type (`config`), config path
171
+ * (`.cursor/hooks.json`), handler types (command, prompt), and all event
172
+ * mappings. Returns null when CAAMP is unavailable at runtime.
173
+ *
174
+ * @returns Provider hook profile or null if CAAMP is unavailable
175
+ * @task T165
176
+ */
177
+ async getProviderProfile() {
178
+ try {
179
+ const { getProviderHookProfile } = await import('@cleocode/caamp');
180
+ return getProviderHookProfile(PROVIDER_ID) ?? null;
181
+ }
182
+ catch {
183
+ return null;
184
+ }
185
+ }
186
+ /**
187
+ * Translate a CAAMP canonical event to its Cursor native name via CAAMP.
188
+ *
189
+ * Calls `toNative(canonical, 'cursor')` from the CAAMP normalizer.
190
+ * Returns null for unsupported events or when CAAMP is unavailable.
191
+ *
192
+ * @param canonical - CAAMP canonical event name (e.g. "PreToolUse")
193
+ * @returns Cursor native event name (e.g. "preToolUse") or null
194
+ * @task T165
195
+ */
196
+ async toNativeEvent(canonical) {
197
+ try {
198
+ const { toNative } = await import('@cleocode/caamp');
199
+ return toNative(canonical, PROVIDER_ID);
200
+ }
201
+ catch {
202
+ // Invert the static map as fallback
203
+ const entry = Object.entries(CURSOR_EVENT_MAP).find(([, v]) => v === canonical);
204
+ return entry?.[0] ?? null;
205
+ }
206
+ }
207
+ }
208
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/providers/cursor/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,4CAA4C;AAC5C,MAAM,WAAW,GAAG,QAAiB,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,gBAAgB,GAA2B;IAC/C,mEAAmE;IACnE,YAAY,EAAE,cAAc;IAC5B,iEAAiE;IACjE,UAAU,EAAE,YAAY;IACxB,yEAAyE;IACzE,kBAAkB,EAAE,cAAc;IAClC,2DAA2D;IAC3D,IAAI,EAAE,kBAAkB;IACxB,iEAAiE;IACjE,UAAU,EAAE,YAAY;IACxB,kEAAkE;IAClE,WAAW,EAAE,aAAa;IAC1B,yEAAyE;IACzE,kBAAkB,EAAE,oBAAoB;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AsB,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,aAAa,CAAC,SAAiB;QACnC,IAAI,CAAC;YACH,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;YACrD,OAAO,QAAQ,CAAC,SAA2C,EAAE,WAAW,CAAC,CAAC;QAC5E,CAAC;QAAC,MAAM,CAAC;YACP,oCAAoC;YACpC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;YAChF,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QAC5B,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * CLEO provider adapter for Cursor AI code editor.
5
+ * Default export is the adapter class for dynamic loading by AdapterManager.
6
+ *
7
+ * @task T5240
8
+ */
9
+ import { CursorAdapter } from './adapter.js';
10
+ export { CursorAdapter } from './adapter.js';
11
+ export { CursorHookProvider } from './hooks.js';
12
+ export { CursorInstallProvider } from './install.js';
13
+ export default CursorAdapter;
14
+ /**
15
+ * Factory function for creating adapter instances.
16
+ * Used by AdapterManager's dynamic import fallback.
17
+ *
18
+ * @remarks
19
+ * This is the primary entry point for dynamic adapter loading.
20
+ * AdapterManager calls this function when it resolves the cursor
21
+ * provider via its import-based discovery mechanism.
22
+ *
23
+ * @returns A new {@link CursorAdapter} instance ready for initialization
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * import { createAdapter } from '@cleocode/adapters/providers/cursor';
28
+ *
29
+ * const adapter = createAdapter();
30
+ * await adapter.initialize('/path/to/project');
31
+ * ```
32
+ */
33
+ export function createAdapter() {
34
+ return new CursorAdapter();
35
+ }
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/cursor/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,eAAe,aAAa,CAAC;AAE7B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC"}