@cleocode/adapters 2026.4.12 → 2026.4.14

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 (73) hide show
  1. package/dist/index.d.ts +23 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +3246 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/providers/claude-code/adapter.d.ts +95 -0
  6. package/dist/providers/claude-code/adapter.d.ts.map +1 -0
  7. package/dist/providers/claude-code/context-monitor.d.ts +35 -0
  8. package/dist/providers/claude-code/context-monitor.d.ts.map +1 -0
  9. package/dist/providers/claude-code/hooks.d.ts +146 -0
  10. package/dist/providers/claude-code/hooks.d.ts.map +1 -0
  11. package/dist/providers/claude-code/index.d.ts +39 -0
  12. package/dist/providers/claude-code/index.d.ts.map +1 -0
  13. package/dist/providers/claude-code/install.d.ts +67 -0
  14. package/dist/providers/claude-code/install.d.ts.map +1 -0
  15. package/dist/providers/claude-code/paths.d.ts +32 -0
  16. package/dist/providers/claude-code/paths.d.ts.map +1 -0
  17. package/dist/providers/claude-code/spawn.d.ts +67 -0
  18. package/dist/providers/claude-code/spawn.d.ts.map +1 -0
  19. package/dist/providers/claude-code/statusline.d.ts +68 -0
  20. package/dist/providers/claude-code/statusline.d.ts.map +1 -0
  21. package/dist/providers/claude-code/task-sync.d.ts +32 -0
  22. package/dist/providers/claude-code/task-sync.d.ts.map +1 -0
  23. package/dist/providers/claude-code/transport.d.ts +25 -0
  24. package/dist/providers/claude-code/transport.d.ts.map +1 -0
  25. package/dist/providers/codex/adapter.d.ts +83 -0
  26. package/dist/providers/codex/adapter.d.ts.map +1 -0
  27. package/dist/providers/codex/hooks.d.ts +91 -0
  28. package/dist/providers/codex/hooks.d.ts.map +1 -0
  29. package/dist/providers/codex/index.d.ts +37 -0
  30. package/dist/providers/codex/index.d.ts.map +1 -0
  31. package/dist/providers/codex/install.d.ts +65 -0
  32. package/dist/providers/codex/install.d.ts.map +1 -0
  33. package/dist/providers/cursor/adapter.d.ts +76 -0
  34. package/dist/providers/cursor/adapter.d.ts.map +1 -0
  35. package/dist/providers/cursor/hooks.d.ts +140 -0
  36. package/dist/providers/cursor/hooks.d.ts.map +1 -0
  37. package/dist/providers/cursor/index.d.ts +34 -0
  38. package/dist/providers/cursor/index.d.ts.map +1 -0
  39. package/dist/providers/cursor/install.d.ts +87 -0
  40. package/dist/providers/cursor/install.d.ts.map +1 -0
  41. package/dist/providers/cursor/spawn.d.ts +50 -0
  42. package/dist/providers/cursor/spawn.d.ts.map +1 -0
  43. package/dist/providers/gemini-cli/adapter.d.ts +84 -0
  44. package/dist/providers/gemini-cli/adapter.d.ts.map +1 -0
  45. package/dist/providers/gemini-cli/hooks.d.ts +99 -0
  46. package/dist/providers/gemini-cli/hooks.d.ts.map +1 -0
  47. package/dist/providers/gemini-cli/index.d.ts +37 -0
  48. package/dist/providers/gemini-cli/index.d.ts.map +1 -0
  49. package/dist/providers/gemini-cli/install.d.ts +65 -0
  50. package/dist/providers/gemini-cli/install.d.ts.map +1 -0
  51. package/dist/providers/kimi/adapter.d.ts +85 -0
  52. package/dist/providers/kimi/adapter.d.ts.map +1 -0
  53. package/dist/providers/kimi/hooks.d.ts +70 -0
  54. package/dist/providers/kimi/hooks.d.ts.map +1 -0
  55. package/dist/providers/kimi/index.d.ts +37 -0
  56. package/dist/providers/kimi/index.d.ts.map +1 -0
  57. package/dist/providers/kimi/install.d.ts +65 -0
  58. package/dist/providers/kimi/install.d.ts.map +1 -0
  59. package/dist/providers/opencode/adapter.d.ts +83 -0
  60. package/dist/providers/opencode/adapter.d.ts.map +1 -0
  61. package/dist/providers/opencode/hooks.d.ts +136 -0
  62. package/dist/providers/opencode/hooks.d.ts.map +1 -0
  63. package/dist/providers/opencode/index.d.ts +35 -0
  64. package/dist/providers/opencode/index.d.ts.map +1 -0
  65. package/dist/providers/opencode/install.d.ts +56 -0
  66. package/dist/providers/opencode/install.d.ts.map +1 -0
  67. package/dist/providers/opencode/spawn.d.ts +94 -0
  68. package/dist/providers/opencode/spawn.d.ts.map +1 -0
  69. package/dist/providers/shared/transcript-reader.d.ts +58 -0
  70. package/dist/providers/shared/transcript-reader.d.ts.map +1 -0
  71. package/dist/registry.d.ts +88 -0
  72. package/dist/registry.d.ts.map +1 -0
  73. package/package.json +3 -3
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Claude Code Adapter
3
+ *
4
+ * Main CLEOProviderAdapter implementation for Anthropic's Claude Code CLI.
5
+ * Provides spawn, hooks, and install capabilities for CLEO integration.
6
+ *
7
+ * @task T5240
8
+ */
9
+ import type { AdapterCapabilities, AdapterHealthStatus, CLEOProviderAdapter } from '@cleocode/contracts';
10
+ import { ClaudeCodeContextMonitorProvider } from './context-monitor.js';
11
+ import { ClaudeCodeHookProvider } from './hooks.js';
12
+ import { ClaudeCodeInstallProvider } from './install.js';
13
+ import { ClaudeCodePathProvider } from './paths.js';
14
+ import { ClaudeCodeSpawnProvider } from './spawn.js';
15
+ import { ClaudeCodeTaskSyncProvider } from './task-sync.js';
16
+ import { ClaudeCodeTransportProvider } from './transport.js';
17
+ /**
18
+ * CLEO provider adapter for Anthropic Claude Code CLI.
19
+ *
20
+ * Bridges CLEO's adapter system with Claude Code's native capabilities:
21
+ * - Hooks: Maps Claude Code events (SessionStart, PostToolUse, etc.) to CAAMP events
22
+ * - Spawn: Launches subagent processes via the `claude` CLI
23
+ * - Install: Manages instruction files and brain observation plugin registration
24
+ *
25
+ * @remarks
26
+ * This is the most feature-complete adapter in the CLEO system, supporting
27
+ * 14 of 16 CAAMP canonical events, subagent spawning via the `claude` CLI,
28
+ * context monitoring with statusline integration, task sync via TodoWrite,
29
+ * and inter-agent transport. It serves as the reference implementation for
30
+ * other provider adapters.
31
+ */
32
+ export declare class ClaudeCodeAdapter implements CLEOProviderAdapter {
33
+ /** Unique provider identifier. */
34
+ readonly id = "claude-code";
35
+ /** Human-readable provider name. */
36
+ readonly name = "Claude Code";
37
+ /** Adapter version string. */
38
+ readonly version = "1.0.0";
39
+ /** Declared capabilities for this provider. */
40
+ capabilities: AdapterCapabilities;
41
+ /** Hook provider for CAAMP event mapping and registration. */
42
+ hooks: ClaudeCodeHookProvider;
43
+ /** Spawn provider for launching subagent processes via `claude` CLI. */
44
+ spawn: ClaudeCodeSpawnProvider;
45
+ /** Install provider for managing instruction files and plugin registration. */
46
+ install: ClaudeCodeInstallProvider;
47
+ /** Path provider for resolving Claude Code directory locations. */
48
+ paths: ClaudeCodePathProvider;
49
+ /** Context monitor for tracking context window usage and statusline output. */
50
+ contextMonitor: ClaudeCodeContextMonitorProvider;
51
+ /** Transport provider for inter-agent communication. */
52
+ transport: ClaudeCodeTransportProvider;
53
+ /** Task sync provider bridging Claude's TodoWrite format to CLEO tasks. */
54
+ taskSync: ClaudeCodeTaskSyncProvider;
55
+ /** Project directory this adapter was initialized with, or null. */
56
+ private projectDir;
57
+ /** Whether {@link initialize} has been called. */
58
+ private initialized;
59
+ constructor();
60
+ /**
61
+ * Initialize the adapter for a given project directory.
62
+ *
63
+ * Validates the environment by checking for the Claude CLI
64
+ * and Claude Code configuration directory.
65
+ *
66
+ * @param projectDir - Root directory of the project
67
+ */
68
+ initialize(projectDir: string): Promise<void>;
69
+ /**
70
+ * Dispose the adapter and clean up resources.
71
+ *
72
+ * Unregisters hooks and releases any tracked state.
73
+ */
74
+ dispose(): Promise<void>;
75
+ /**
76
+ * Run a health check to verify Claude Code is accessible.
77
+ *
78
+ * Checks:
79
+ * 1. Adapter has been initialized
80
+ * 2. Claude CLI is available in PATH
81
+ * 3. ~/.claude/ configuration directory exists
82
+ *
83
+ * @returns Health status with details about each check
84
+ */
85
+ healthCheck(): Promise<AdapterHealthStatus>;
86
+ /**
87
+ * Check whether the adapter has been initialized.
88
+ */
89
+ isInitialized(): boolean;
90
+ /**
91
+ * Get the project directory this adapter was initialized with.
92
+ */
93
+ getProjectDir(): string | null;
94
+ }
95
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAI7D;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAkB,YAAW,mBAAmB;IAC3D,kCAAkC;IAClC,QAAQ,CAAC,EAAE,iBAAiB;IAC5B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,WAAW;IAE3B,+CAA+C;IAC/C,YAAY,EAAE,mBAAmB,CA6B/B;IAEF,8DAA8D;IAC9D,KAAK,EAAE,sBAAsB,CAAC;IAC9B,wEAAwE;IACxE,KAAK,EAAE,uBAAuB,CAAC;IAC/B,+EAA+E;IAC/E,OAAO,EAAE,yBAAyB,CAAC;IACnC,mEAAmE;IACnE,KAAK,EAAE,sBAAsB,CAAC;IAC9B,+EAA+E;IAC/E,cAAc,EAAE,gCAAgC,CAAC;IACjD,wDAAwD;IACxD,SAAS,EAAE,2BAA2B,CAAC;IACvC,2EAA2E;IAC3E,QAAQ,EAAE,0BAA0B,CAAC;IAErC,oEAAoE;IACpE,OAAO,CAAC,UAAU,CAAuB;IACzC,kDAAkD;IAClD,OAAO,CAAC,WAAW,CAAS;;IAY5B;;;;;;;OAOG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnD;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B;;;;;;;;;OASG;IACG,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAyCjD;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,aAAa,IAAI,MAAM,GAAG,IAAI;CAG/B"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Claude Code context monitor provider.
3
+ *
4
+ * Implements AdapterContextMonitorProvider for Claude Code's context window
5
+ * tracking and statusline integration.
6
+ *
7
+ * @task T5240
8
+ */
9
+ import type { AdapterContextMonitorProvider } from '@cleocode/contracts';
10
+ /**
11
+ * Context monitor provider for Claude Code.
12
+ *
13
+ * Processes context window JSON from Claude Code and writes state files
14
+ * for statusline display. Also provides statusline configuration
15
+ * and setup instructions specific to Claude Code's settings.json.
16
+ *
17
+ * @remarks
18
+ * The provider writes a JSON state file to `.cleo/context-states/.context-state.json`
19
+ * which can be read by external statusline scripts (e.g. tmux, starship).
20
+ * Context thresholds at 50%, 70%, 85%, and 95% map to warning, caution,
21
+ * critical, and emergency status levels respectively.
22
+ */
23
+ export declare class ClaudeCodeContextMonitorProvider implements AdapterContextMonitorProvider {
24
+ /** Path provider for resolving Claude Code directory locations. */
25
+ private pathProvider;
26
+ /** Process raw context window JSON and return a formatted summary string. */
27
+ processContextInput(input: unknown, cwd?: string): Promise<string>;
28
+ /** Check the current statusline integration status in Claude Code settings. */
29
+ checkStatuslineIntegration(): 'configured' | 'not_configured' | 'custom_no_cleo' | 'no_settings';
30
+ /** Get the recommended statusline configuration object for Claude Code settings. */
31
+ getStatuslineConfig(): Record<string, unknown>;
32
+ /** Get human-readable setup instructions for enabling context monitoring. */
33
+ getSetupInstructions(): string;
34
+ }
35
+ //# sourceMappingURL=context-monitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-monitor.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/context-monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAkCzE;;;;;;;;;;;;GAYG;AACH,qBAAa,gCAAiC,YAAW,6BAA6B;IACpF,mEAAmE;IACnE,OAAO,CAAC,YAAY,CAAgC;IAEpD,6EAA6E;IACvE,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0DxE,+EAA+E;IAC/E,0BAA0B,IAAI,YAAY,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,aAAa;IAsChG,oFAAoF;IACpF,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAS9C,6EAA6E;IAC7E,oBAAoB,IAAI,MAAM;CAY/B"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Claude Code Hook Provider
3
+ *
4
+ * Maps Claude Code's native hook events to CAAMP canonical hook events.
5
+ * Claude Code supports 14 of 16 canonical events (all except PreModel, PostModel).
6
+ *
7
+ * Event translation uses CAAMP normalizer APIs:
8
+ * - `toCanonical(nativeName, 'claude-code')` for runtime event name resolution
9
+ * - `getSupportedEvents('claude-code')` to enumerate supported canonical events
10
+ * - `getProviderHookProfile('claude-code')` for the full provider profile
11
+ *
12
+ * A static map derived from CAAMP 1.9.1 hook-mappings.json is maintained as
13
+ * a fallback for environments where CAAMP's runtime resolution is unavailable.
14
+ *
15
+ * @task T164
16
+ * @epic T134
17
+ */
18
+ import type { AdapterHookProvider } from '@cleocode/contracts';
19
+ /**
20
+ * Hook provider for Claude Code.
21
+ *
22
+ * Claude Code registers hooks via its global config at `~/.claude/settings.json`.
23
+ * Supported handler types: command, http, prompt, agent.
24
+ *
25
+ * Event mapping is based on `getProviderHookProfile('claude-code')` from
26
+ * CAAMP 1.9.1. Async accessors (`getSupportedCanonicalEvents`,
27
+ * `getProviderProfile`) call CAAMP directly when available.
28
+ *
29
+ * Since hooks are registered through the config system (managed by the install
30
+ * provider), `registerNativeHooks` and `unregisterNativeHooks` track registration
31
+ * state without performing filesystem operations.
32
+ *
33
+ * @remarks
34
+ * Claude Code is the only provider that supports all 14 of its declared
35
+ * canonical events at runtime. The static event map is maintained as a
36
+ * synchronous fallback; async methods like {@link getSupportedCanonicalEvents}
37
+ * and {@link getProviderProfile} call CAAMP directly when available.
38
+ *
39
+ * @task T164
40
+ * @epic T134
41
+ */
42
+ export declare class ClaudeCodeHookProvider implements AdapterHookProvider {
43
+ /** Whether hooks have been registered for the current session. */
44
+ private registered;
45
+ /**
46
+ * Map a Claude Code native event name to a CAAMP canonical hook event name.
47
+ *
48
+ * Looks up the native event name in the map derived from
49
+ * `getProviderHookProfile('claude-code').mappings` (CAAMP 1.9.1).
50
+ * Returns null for unrecognised events (e.g. PreModel, PostModel which
51
+ * Claude Code does not support).
52
+ *
53
+ * @param providerEvent - Claude Code native event (e.g. "UserPromptSubmit", "Stop")
54
+ * @returns CAAMP canonical event name, or null if unmapped
55
+ * @task T164
56
+ */
57
+ mapProviderEvent(providerEvent: string): string | null;
58
+ /**
59
+ * Register native hooks for a project.
60
+ *
61
+ * For Claude Code, hooks are registered via the config system
62
+ * (`~/.claude/settings.json`), managed by the install provider.
63
+ * This method marks hooks as registered without performing filesystem operations.
64
+ *
65
+ * Iterating supported events is handled at install time using
66
+ * `getSupportedCanonicalEvents()` to enumerate all 14 supported hooks.
67
+ *
68
+ * @param _projectDir - Project directory (unused; Claude Code uses global config)
69
+ * @task T164
70
+ */
71
+ registerNativeHooks(_projectDir: string): Promise<void>;
72
+ /**
73
+ * Unregister native hooks.
74
+ *
75
+ * For Claude Code, this is a no-op since hooks are managed through the config
76
+ * system. Unregistration happens via the install provider's uninstall method.
77
+ *
78
+ * @task T164
79
+ */
80
+ unregisterNativeHooks(): Promise<void>;
81
+ /**
82
+ * Check whether hooks have been registered via `registerNativeHooks`.
83
+ */
84
+ isRegistered(): boolean;
85
+ /**
86
+ * Get the native→canonical event mapping for introspection and debugging.
87
+ *
88
+ * Returns the map derived from `getProviderHookProfile('claude-code').mappings`
89
+ * (CAAMP 1.9.1). Use `getSupportedCanonicalEvents()` to enumerate canonical
90
+ * names via live CAAMP APIs.
91
+ *
92
+ * @returns Immutable record of native event name → canonical event name
93
+ */
94
+ getEventMap(): Readonly<Record<string, string>>;
95
+ /**
96
+ * Enumerate supported canonical events via CAAMP's `getSupportedEvents()`.
97
+ *
98
+ * Calls `getSupportedEvents('claude-code')` from the CAAMP normalizer to
99
+ * get the authoritative list. Claude Code supports 14 of 16 canonical events
100
+ * (PreModel and PostModel are not supported). Falls back to the values of
101
+ * the static event map when CAAMP is unavailable at runtime.
102
+ *
103
+ * @returns Array of CAAMP canonical event names supported by Claude Code
104
+ * @task T164
105
+ */
106
+ getSupportedCanonicalEvents(): Promise<string[]>;
107
+ /**
108
+ * Retrieve the full provider hook profile from CAAMP.
109
+ *
110
+ * Calls `getProviderHookProfile('claude-code')` from the CAAMP normalizer to
111
+ * get the complete profile: hook system type (`config`), config path
112
+ * (`~/.claude/settings.json`), handler types, and all event mappings.
113
+ * Returns null when CAAMP is unavailable at runtime.
114
+ *
115
+ * @returns Provider hook profile or null if CAAMP is unavailable
116
+ * @task T164
117
+ */
118
+ getProviderProfile(): Promise<unknown | null>;
119
+ /**
120
+ * Translate a CAAMP canonical event to its Claude Code native name via CAAMP.
121
+ *
122
+ * Calls `toNative(canonical, 'claude-code')` from the CAAMP normalizer.
123
+ * Returns null for unsupported events (PreModel, PostModel) or when
124
+ * CAAMP is unavailable.
125
+ *
126
+ * @param canonical - CAAMP canonical event name (e.g. "PromptSubmit")
127
+ * @returns Claude Code native event name or null
128
+ * @task T164
129
+ */
130
+ toNativeEvent(canonical: string): Promise<string | null>;
131
+ /**
132
+ * Extract a plain-text transcript from Claude Code session JSONL files.
133
+ *
134
+ * Reads the most recent .jsonl file under `~/.claude/projects/` and
135
+ * extracts user/assistant turn text into a flat string for brain
136
+ * observation extraction.
137
+ *
138
+ * Returns null when no session data is found or on any read error.
139
+ *
140
+ * @param _sessionId - CLEO session ID (unused; reads the most recent file)
141
+ * @param _projectDir - Project directory (unused; Claude Code uses global paths)
142
+ * @task T144 @epic T134
143
+ */
144
+ getTranscript(_sessionId: string, _projectDir: string): Promise<string | null>;
145
+ }
146
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AA8C/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,kEAAkE;IAClE,OAAO,CAAC,UAAU,CAAS;IAE3B;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAItD;;;;;;;;;;;;OAYG;IACG,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D;;;;;;;OAOG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;;;;;;;OAQG;IACH,WAAW,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAI/C;;;;;;;;;;OAUG;IACG,2BAA2B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAStD;;;;;;;;;;OAUG;IACG,kBAAkB,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IASnD;;;;;;;;;;OAUG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAW9D;;;;;;;;;;;;OAYG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CA2DrF"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * CLEO provider adapter for Anthropic Claude Code CLI.
5
+ * Default export is the adapter class for dynamic loading by AdapterManager.
6
+ *
7
+ * @task T5240
8
+ */
9
+ import { ClaudeCodeAdapter } from './adapter.js';
10
+ export { ClaudeCodeAdapter } from './adapter.js';
11
+ export { ClaudeCodeContextMonitorProvider } from './context-monitor.js';
12
+ export { ClaudeCodeHookProvider } from './hooks.js';
13
+ export { ClaudeCodeInstallProvider } from './install.js';
14
+ export { ClaudeCodePathProvider } from './paths.js';
15
+ export { ClaudeCodeSpawnProvider } from './spawn.js';
16
+ export { checkStatuslineIntegration, getSetupInstructions, getStatuslineConfig, } from './statusline.js';
17
+ export { ClaudeCodeTransportProvider } from './transport.js';
18
+ export default ClaudeCodeAdapter;
19
+ /**
20
+ * Factory function for creating adapter instances.
21
+ * Used by AdapterManager's dynamic import fallback.
22
+ *
23
+ * @remarks
24
+ * This is the primary entry point for dynamic adapter loading.
25
+ * AdapterManager calls this function when it resolves the claude-code
26
+ * provider via its import-based discovery mechanism.
27
+ *
28
+ * @returns A new {@link ClaudeCodeAdapter} instance ready for initialization
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { createAdapter } from '@cleocode/adapters/providers/claude-code';
33
+ *
34
+ * const adapter = createAdapter();
35
+ * await adapter.initialize('/path/to/project');
36
+ * ```
37
+ */
38
+ export declare function createAdapter(): ClaudeCodeAdapter;
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAE7D,eAAe,iBAAiB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,IAAI,iBAAiB,CAEjD"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Claude Code Install Provider
3
+ *
4
+ * Handles CLEO installation into Claude Code environments:
5
+ * - Ensures CLAUDE.md has CLEO @-references
6
+ * - Manages plugin registration in ~/.claude/settings.json
7
+ *
8
+ * Migrated from src/core/install/claude-plugin.ts
9
+ *
10
+ * @task T5240
11
+ */
12
+ import type { AdapterInstallProvider, InstallOptions, InstallResult } from '@cleocode/contracts';
13
+ /**
14
+ * Install provider for Claude Code.
15
+ *
16
+ * Manages CLEO's integration with Claude Code by:
17
+ * 1. Ensuring CLAUDE.md contains @-references to CLEO instruction files
18
+ * 2. Registering the brain observation plugin in ~/.claude/settings.json
19
+ *
20
+ * @remarks
21
+ * Installation is idempotent -- running install multiple times on the same
22
+ * project produces the same result. The provider disables the legacy
23
+ * `claude-mem\@thedotmack` plugin if present and enables the unified
24
+ * `cleo\@cleocode` plugin instead.
25
+ */
26
+ export declare class ClaudeCodeInstallProvider implements AdapterInstallProvider {
27
+ /**
28
+ * Install CLEO into a Claude Code project.
29
+ *
30
+ * @param options - Installation options including project directory
31
+ * @returns Result describing what was installed
32
+ */
33
+ install(options: InstallOptions): Promise<InstallResult>;
34
+ /**
35
+ * Uninstall CLEO from the current Claude Code project.
36
+ *
37
+ * Does not remove CLAUDE.md references (they are harmless if CLEO is not present).
38
+ */
39
+ uninstall(): Promise<void>;
40
+ /**
41
+ * Check whether CLEO is installed in the current environment.
42
+ *
43
+ * Checks for plugin enabled in ~/.claude/settings.json.
44
+ */
45
+ isInstalled(): Promise<boolean>;
46
+ /**
47
+ * Ensure CLAUDE.md contains @-references to CLEO instruction files.
48
+ *
49
+ * Creates CLAUDE.md if it does not exist. Appends any missing references.
50
+ *
51
+ * @param projectDir - Project root directory
52
+ */
53
+ ensureInstructionReferences(projectDir: string): Promise<void>;
54
+ /**
55
+ * Update CLAUDE.md with CLEO @-references.
56
+ *
57
+ * @returns true if the file was created or modified
58
+ */
59
+ private updateInstructionFile;
60
+ /**
61
+ * Register the CLEO brain plugin in ~/.claude/settings.json.
62
+ *
63
+ * @returns Description of what was registered, or null if no change needed
64
+ */
65
+ private registerPlugin;
66
+ }
67
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKjG;;;;;;;;;;;;GAYG;AACH,qBAAa,yBAA0B,YAAW,sBAAsB;IACtE;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IA0B9D;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAEhC;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAkBrC;;;;;;OAMG;IACG,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IA+B7B;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAiCvB"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Claude Code path provider.
3
+ *
4
+ * Implements AdapterPathProvider with Claude Code-specific directory locations.
5
+ *
6
+ * @task T5240
7
+ */
8
+ import type { AdapterPathProvider } from '@cleocode/contracts';
9
+ /**
10
+ * Path provider for Anthropic Claude Code CLI.
11
+ *
12
+ * Resolves Claude Code's standard directory layout:
13
+ * - Config dir: ~/.claude (or CLAUDE_HOME)
14
+ * - Settings: ~/.claude/settings.json (or CLAUDE_SETTINGS)
15
+ * - Agents: ~/.claude/agents
16
+ * - Memory DB: ~/.claude-mem/claude-mem.db (or CLAUDE_MEM_DB)
17
+ *
18
+ * @remarks
19
+ * All paths respect environment variable overrides for CI and non-standard
20
+ * installations. When env vars are unset, the canonical default paths are used.
21
+ */
22
+ export declare class ClaudeCodePathProvider implements AdapterPathProvider {
23
+ /** Get the provider's root configuration directory. */
24
+ getProviderDir(): string;
25
+ /** Get the path to the provider's settings file, or null if unavailable. */
26
+ getSettingsPath(): string | null;
27
+ /** Get the directory where agents are installed, or null if unsupported. */
28
+ getAgentInstallDir(): string | null;
29
+ /** Get the path to the provider's memory database, or null if unsupported. */
30
+ getMemoryDbPath(): string | null;
31
+ }
32
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,uDAAuD;IACvD,cAAc,IAAI,MAAM;IAIxB,4EAA4E;IAC5E,eAAe,IAAI,MAAM,GAAG,IAAI;IAIhC,4EAA4E;IAC5E,kBAAkB,IAAI,MAAM,GAAG,IAAI;IAInC,8EAA8E;IAC9E,eAAe,IAAI,MAAM,GAAG,IAAI;CAGjC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Claude Code Spawn Provider
3
+ *
4
+ * Implements AdapterSpawnProvider for Claude Code CLI.
5
+ * Migrated from src/core/spawn/adapters/claude-code-adapter.ts
6
+ *
7
+ * Uses the native `claude` CLI to spawn subagent processes with prompts
8
+ * written to temporary files. Processes run detached and are tracked
9
+ * by PID for listing and termination.
10
+ *
11
+ * @task T5240
12
+ */
13
+ import type { AdapterSpawnProvider, SpawnContext, SpawnResult } from '@cleocode/contracts';
14
+ /**
15
+ * Spawn provider for Claude Code.
16
+ *
17
+ * Spawns detached Claude CLI processes for subagent execution.
18
+ * Each spawn writes its prompt to a temporary file, then runs
19
+ * `claude --allow-insecure --no-upgrade-check <tmpFile>` as a
20
+ * detached, unref'd child process.
21
+ *
22
+ * @remarks
23
+ * The provider uses `--allow-insecure --no-upgrade-check` flags to
24
+ * ensure the Claude CLI starts without interactive prompts. Prompts are
25
+ * written to temporary files under `/tmp/` and cleaned up after the
26
+ * child process exits. Processes are tracked by instance ID in an
27
+ * in-memory map and verified via `kill(pid, 0)` liveness checks.
28
+ */
29
+ export declare class ClaudeCodeSpawnProvider implements AdapterSpawnProvider {
30
+ /** Map of instance IDs to tracked process info. */
31
+ private processMap;
32
+ /**
33
+ * Check if the Claude CLI is available in PATH.
34
+ *
35
+ * @returns true if `claude` is found via `which`
36
+ */
37
+ canSpawn(): Promise<boolean>;
38
+ /**
39
+ * Spawn a subagent via Claude CLI.
40
+ *
41
+ * Writes the prompt to a temporary file and spawns a detached Claude
42
+ * process. The process runs independently of the parent.
43
+ *
44
+ * @param context - Spawn context with taskId, prompt, and options
45
+ * @returns Spawn result with instance ID and status
46
+ */
47
+ spawn(context: SpawnContext): Promise<SpawnResult>;
48
+ /**
49
+ * List currently running Claude subagent processes.
50
+ *
51
+ * Checks each tracked process via kill(pid, 0) to verify it is still alive.
52
+ * Dead processes are automatically cleaned from the tracking map.
53
+ *
54
+ * @returns Array of spawn results for running processes
55
+ */
56
+ listRunning(): Promise<SpawnResult[]>;
57
+ /**
58
+ * Terminate a running spawn by instance ID.
59
+ *
60
+ * Sends SIGTERM to the tracked process. If the process is not found
61
+ * or has already exited, this is a no-op.
62
+ *
63
+ * @param instanceId - ID of the spawn instance to terminate
64
+ */
65
+ terminate(instanceId: string): Promise<void>;
66
+ }
67
+ //# sourceMappingURL=spawn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAY3F;;;;;;;;;;;;;;GAcG;AACH,qBAAa,uBAAwB,YAAW,oBAAoB;IAClE,mDAAmD;IACnD,OAAO,CAAC,UAAU,CAAqC;IAEvD;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IASlC;;;;;;;;OAQG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAuExD;;;;;;;OAOG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAqB3C;;;;;;;OAOG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWnD"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Statusline integration for the Claude Code adapter.
3
+ *
4
+ * Implements the statusline portion of AdapterContextMonitorProvider.
5
+ * Checks and configures Claude Code status line for context monitoring.
6
+ *
7
+ * @task T5240
8
+ */
9
+ type StatuslineStatus = 'configured' | 'not_configured' | 'custom_no_cleo' | 'no_settings';
10
+ /**
11
+ * Check if statusline integration is configured.
12
+ * Returns the current integration status.
13
+ *
14
+ * @remarks
15
+ * Reads Claude Code's settings.json and inspects the `statusLine` field
16
+ * to determine whether CLEO context monitoring is active.
17
+ *
18
+ * @returns One of: 'configured', 'not_configured', 'custom_no_cleo', 'no_settings'
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { checkStatuslineIntegration } from './statusline.js';
23
+ *
24
+ * const status = checkStatuslineIntegration();
25
+ * if (status === 'not_configured') {
26
+ * console.log('Run cleo install to set up context monitoring');
27
+ * }
28
+ * ```
29
+ */
30
+ export declare function checkStatuslineIntegration(): StatuslineStatus;
31
+ /**
32
+ * Get the statusline setup command for Claude Code settings.
33
+ *
34
+ * @remarks
35
+ * Returns a JSON-serializable object that can be merged into
36
+ * Claude Code's settings.json to enable context monitoring.
37
+ *
38
+ * @param cleoHome - Absolute path to the CLEO home directory
39
+ * @returns Settings object containing the statusLine configuration
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import { getStatuslineConfig } from './statusline.js';
44
+ *
45
+ * const config = getStatuslineConfig('/home/user/.cleo');
46
+ * ```
47
+ */
48
+ export declare function getStatuslineConfig(cleoHome: string): Record<string, unknown>;
49
+ /**
50
+ * Get human-readable setup instructions.
51
+ *
52
+ * @remarks
53
+ * Returns a multi-line string with file path, JSON config, and explanation
54
+ * suitable for display to the user.
55
+ *
56
+ * @param cleoHome - Absolute path to the CLEO home directory
57
+ * @returns Formatted setup instructions string
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * import { getSetupInstructions } from './statusline.js';
62
+ *
63
+ * console.log(getSetupInstructions('/home/user/.cleo'));
64
+ * ```
65
+ */
66
+ export declare function getSetupInstructions(cleoHome: string): string;
67
+ export {};
68
+ //# sourceMappingURL=statusline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusline.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/statusline.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,KAAK,gBAAgB,GAAG,YAAY,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAa3F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,0BAA0B,IAAI,gBAAgB,CAwC7D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAO7E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAW7D"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Claude Code TaskSyncProvider — bridges Claude's TodoWrite format
3
+ * to the provider-agnostic reconciliation system.
4
+ *
5
+ * All Claude Code / TodoWrite-specific parsing lives here.
6
+ * The core reconciliation engine never sees TodoWrite formats.
7
+ */
8
+ import type { ExternalTask, ExternalTaskProvider } from '@cleocode/contracts';
9
+ /**
10
+ * Claude Code TaskSyncProvider.
11
+ *
12
+ * Reads Claude's TodoWrite JSON state, parses [T001]-prefixed task IDs
13
+ * and status, and returns normalized ExternalTask[].
14
+ *
15
+ * Optional: accepts a custom file path for testing.
16
+ *
17
+ * @remarks
18
+ * TodoWrite items with `[T001]`-style prefixes are mapped to their CLEO
19
+ * task IDs. Items without a prefix receive a synthetic `tw-new-N` ID
20
+ * for reconciliation. The provider reads from
21
+ * `.cleo/sync/todowrite-state.json` by default.
22
+ */
23
+ export declare class ClaudeCodeTaskSyncProvider implements ExternalTaskProvider {
24
+ /** Optional override path for the TodoWrite state file (used in tests). */
25
+ private readonly customFilePath?;
26
+ constructor(options?: {
27
+ filePath?: string;
28
+ });
29
+ /** Retrieve external tasks from Claude's TodoWrite state file. */
30
+ getExternalTasks(projectDir: string): Promise<ExternalTask[]>;
31
+ }
32
+ //# sourceMappingURL=task-sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-sync.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/task-sync.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAsB,MAAM,qBAAqB,CAAC;AAkElG;;;;;;;;;;;;;GAaG;AACH,qBAAa,0BAA2B,YAAW,oBAAoB;IACrE,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAS;gBAE7B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;IAI3C,kEAAkE;IAC5D,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAgDpE"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Transport provider for the Claude Code adapter.
3
+ *
4
+ * Implements AdapterTransportProvider to supply Claude Code's
5
+ * native inter-agent transport mechanism.
6
+ *
7
+ * @task T5240
8
+ */
9
+ import type { AdapterTransportProvider } from '@cleocode/contracts';
10
+ /**
11
+ * Transport provider for Claude Code inter-agent communication.
12
+ *
13
+ * @remarks
14
+ * Currently returns null from {@link createTransport} because actual transport
15
+ * creation is handled by the signaldock factory which checks for this adapter's
16
+ * transport capability flag. Full wiring will be completed in Phase 5 of the
17
+ * adapter system rollout.
18
+ */
19
+ export declare class ClaudeCodeTransportProvider implements AdapterTransportProvider {
20
+ /** Provider-specific transport name used for capability negotiation. */
21
+ readonly transportName = "claude-code";
22
+ /** Create a transport instance for inter-agent messaging. */
23
+ createTransport(): unknown;
24
+ }
25
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/providers/claude-code/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEpE;;;;;;;;GAQG;AACH,qBAAa,2BAA4B,YAAW,wBAAwB;IAC1E,wEAAwE;IACxE,QAAQ,CAAC,aAAa,iBAAiB;IAEvC,6DAA6D;IAC7D,eAAe,IAAI,OAAO;CAM3B"}