@cleocode/adapters 2026.3.56 → 2026.3.58
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.
- package/dist/providers/claude-code/adapter.js +154 -0
- package/dist/providers/claude-code/adapter.js.map +1 -0
- package/dist/providers/claude-code/context-monitor.js +148 -0
- package/dist/providers/claude-code/context-monitor.js.map +1 -0
- package/dist/providers/claude-code/hooks.js +77 -0
- package/dist/providers/claude-code/hooks.js.map +1 -0
- package/dist/providers/claude-code/index.js +26 -0
- package/dist/providers/claude-code/index.js.map +1 -0
- package/dist/providers/claude-code/install.js +234 -0
- package/dist/providers/claude-code/install.js.map +1 -0
- package/dist/providers/claude-code/paths.js +33 -0
- package/dist/providers/claude-code/paths.js.map +1 -0
- package/dist/providers/claude-code/spawn.js +164 -0
- package/dist/providers/claude-code/spawn.js.map +1 -0
- package/dist/providers/claude-code/statusline.js +86 -0
- package/dist/providers/claude-code/statusline.js.map +1 -0
- package/dist/providers/claude-code/task-sync.js +111 -0
- package/dist/providers/claude-code/task-sync.js.map +1 -0
- package/dist/providers/claude-code/transport.js +18 -0
- package/dist/providers/claude-code/transport.js.map +1 -0
- package/dist/providers/cursor/adapter.js +124 -0
- package/dist/providers/cursor/adapter.js.map +1 -0
- package/dist/providers/cursor/hooks.js +55 -0
- package/dist/providers/cursor/hooks.js.map +1 -0
- package/dist/providers/cursor/index.js +21 -0
- package/dist/providers/cursor/index.js.map +1 -0
- package/dist/providers/cursor/install.js +238 -0
- package/dist/providers/cursor/install.js.map +1 -0
- package/dist/providers/cursor/spawn.js +59 -0
- package/dist/providers/cursor/spawn.js.map +1 -0
- package/dist/providers/opencode/adapter.js +144 -0
- package/dist/providers/opencode/adapter.js.map +1 -0
- package/dist/providers/opencode/hooks.js +89 -0
- package/dist/providers/opencode/hooks.js.map +1 -0
- package/dist/providers/opencode/index.js +22 -0
- package/dist/providers/opencode/index.js.map +1 -0
- package/dist/providers/opencode/install.js +180 -0
- package/dist/providers/opencode/install.js.map +1 -0
- package/dist/providers/opencode/spawn.js +219 -0
- package/dist/providers/opencode/spawn.js.map +1 -0
- package/dist/registry.js +55 -0
- package/dist/registry.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code path provider.
|
|
3
|
+
*
|
|
4
|
+
* Implements AdapterPathProvider with Claude Code-specific directory locations.
|
|
5
|
+
*
|
|
6
|
+
* @task T5240
|
|
7
|
+
*/
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
/**
|
|
11
|
+
* Path provider for Anthropic Claude Code CLI.
|
|
12
|
+
*
|
|
13
|
+
* Resolves Claude Code's standard directory layout:
|
|
14
|
+
* - Config dir: ~/.claude (or CLAUDE_HOME)
|
|
15
|
+
* - Settings: ~/.claude/settings.json (or CLAUDE_SETTINGS)
|
|
16
|
+
* - Agents: ~/.claude/agents
|
|
17
|
+
* - Memory DB: ~/.claude-mem/claude-mem.db (or CLAUDE_MEM_DB)
|
|
18
|
+
*/
|
|
19
|
+
export class ClaudeCodePathProvider {
|
|
20
|
+
getProviderDir() {
|
|
21
|
+
return process.env['CLAUDE_HOME'] ?? join(homedir(), '.claude');
|
|
22
|
+
}
|
|
23
|
+
getSettingsPath() {
|
|
24
|
+
return process.env['CLAUDE_SETTINGS'] ?? join(this.getProviderDir(), 'settings.json');
|
|
25
|
+
}
|
|
26
|
+
getAgentInstallDir() {
|
|
27
|
+
return join(this.getProviderDir(), 'agents');
|
|
28
|
+
}
|
|
29
|
+
getMemoryDbPath() {
|
|
30
|
+
return process.env['CLAUDE_MEM_DB'] ?? join(homedir(), '.claude-mem', 'claude-mem.db');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/providers/claude-code/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;;;;;;GAQG;AACH,MAAM,OAAO,sBAAsB;IACjC,cAAc;QACZ,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;IAED,eAAe;QACb,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,eAAe,CAAC,CAAC;IACxF,CAAC;IAED,kBAAkB;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,eAAe;QACb,OAAO,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;IACzF,CAAC;CACF"}
|
|
@@ -0,0 +1,164 @@
|
|
|
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 { exec, spawn as nodeSpawn } from 'node:child_process';
|
|
14
|
+
import { unlink, writeFile } from 'node:fs/promises';
|
|
15
|
+
import { promisify } from 'node:util';
|
|
16
|
+
import { getErrorMessage } from '@cleocode/contracts';
|
|
17
|
+
const execAsync = promisify(exec);
|
|
18
|
+
/**
|
|
19
|
+
* Spawn provider for Claude Code.
|
|
20
|
+
*
|
|
21
|
+
* Spawns detached Claude CLI processes for subagent execution.
|
|
22
|
+
* Each spawn writes its prompt to a temporary file, then runs
|
|
23
|
+
* `claude --allow-insecure --no-upgrade-check <tmpFile>` as a
|
|
24
|
+
* detached, unref'd child process.
|
|
25
|
+
*/
|
|
26
|
+
export class ClaudeCodeSpawnProvider {
|
|
27
|
+
/** Map of instance IDs to tracked process info. */
|
|
28
|
+
processMap = new Map();
|
|
29
|
+
/**
|
|
30
|
+
* Check if the Claude CLI is available in PATH.
|
|
31
|
+
*
|
|
32
|
+
* @returns true if `claude` is found via `which`
|
|
33
|
+
*/
|
|
34
|
+
async canSpawn() {
|
|
35
|
+
try {
|
|
36
|
+
await execAsync('which claude');
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Spawn a subagent via Claude CLI.
|
|
45
|
+
*
|
|
46
|
+
* Writes the prompt to a temporary file and spawns a detached Claude
|
|
47
|
+
* process. The process runs independently of the parent.
|
|
48
|
+
*
|
|
49
|
+
* @param context - Spawn context with taskId, prompt, and options
|
|
50
|
+
* @returns Spawn result with instance ID and status
|
|
51
|
+
*/
|
|
52
|
+
async spawn(context) {
|
|
53
|
+
const instanceId = `claude-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
54
|
+
const startTime = new Date().toISOString();
|
|
55
|
+
let tmpFile;
|
|
56
|
+
try {
|
|
57
|
+
tmpFile = `/tmp/claude-spawn-${instanceId}.txt`;
|
|
58
|
+
await writeFile(tmpFile, context.prompt, 'utf-8');
|
|
59
|
+
const args = ['--allow-insecure', '--no-upgrade-check', tmpFile];
|
|
60
|
+
const spawnOpts = {
|
|
61
|
+
detached: true,
|
|
62
|
+
stdio: 'ignore',
|
|
63
|
+
};
|
|
64
|
+
if (context.workingDirectory) {
|
|
65
|
+
spawnOpts.cwd = context.workingDirectory;
|
|
66
|
+
}
|
|
67
|
+
const child = nodeSpawn('claude', args, spawnOpts);
|
|
68
|
+
child.unref();
|
|
69
|
+
if (child.pid) {
|
|
70
|
+
this.processMap.set(instanceId, {
|
|
71
|
+
pid: child.pid,
|
|
72
|
+
taskId: context.taskId,
|
|
73
|
+
startTime,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const capturedTmpFile = tmpFile;
|
|
77
|
+
child.on('exit', async () => {
|
|
78
|
+
this.processMap.delete(instanceId);
|
|
79
|
+
try {
|
|
80
|
+
await unlink(capturedTmpFile);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// Ignore cleanup errors
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
instanceId,
|
|
88
|
+
taskId: context.taskId,
|
|
89
|
+
providerId: 'claude-code',
|
|
90
|
+
status: 'running',
|
|
91
|
+
startTime,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
// Log spawn failure for debugging
|
|
96
|
+
console.error(`[ClaudeCodeSpawnProvider] Failed to spawn: ${getErrorMessage(error)}`);
|
|
97
|
+
if (tmpFile) {
|
|
98
|
+
try {
|
|
99
|
+
await unlink(tmpFile);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Ignore cleanup errors
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
instanceId,
|
|
107
|
+
taskId: context.taskId,
|
|
108
|
+
providerId: 'claude-code',
|
|
109
|
+
status: 'failed',
|
|
110
|
+
startTime,
|
|
111
|
+
endTime: new Date().toISOString(),
|
|
112
|
+
error: getErrorMessage(error),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* List currently running Claude subagent processes.
|
|
118
|
+
*
|
|
119
|
+
* Checks each tracked process via kill(pid, 0) to verify it is still alive.
|
|
120
|
+
* Dead processes are automatically cleaned from the tracking map.
|
|
121
|
+
*
|
|
122
|
+
* @returns Array of spawn results for running processes
|
|
123
|
+
*/
|
|
124
|
+
async listRunning() {
|
|
125
|
+
const running = [];
|
|
126
|
+
for (const [instanceId, tracked] of this.processMap.entries()) {
|
|
127
|
+
try {
|
|
128
|
+
process.kill(tracked.pid, 0);
|
|
129
|
+
running.push({
|
|
130
|
+
instanceId,
|
|
131
|
+
taskId: tracked.taskId,
|
|
132
|
+
providerId: 'claude-code',
|
|
133
|
+
status: 'running',
|
|
134
|
+
startTime: tracked.startTime,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
this.processMap.delete(instanceId);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return running;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Terminate a running spawn by instance ID.
|
|
145
|
+
*
|
|
146
|
+
* Sends SIGTERM to the tracked process. If the process is not found
|
|
147
|
+
* or has already exited, this is a no-op.
|
|
148
|
+
*
|
|
149
|
+
* @param instanceId - ID of the spawn instance to terminate
|
|
150
|
+
*/
|
|
151
|
+
async terminate(instanceId) {
|
|
152
|
+
const tracked = this.processMap.get(instanceId);
|
|
153
|
+
if (!tracked)
|
|
154
|
+
return;
|
|
155
|
+
try {
|
|
156
|
+
process.kill(tracked.pid, 'SIGTERM');
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
// Process may have already exited
|
|
160
|
+
}
|
|
161
|
+
this.processMap.delete(instanceId);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=spawn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../../src/providers/claude-code/spawn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAA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,IAAI,EAAE,CAAC,WAAW,EAAE;gBACjC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC;aAC9B,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,OAAO,GAAkB,EAAE,CAAC;QAElC,KAAK,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;YAC9D,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBAC7B,OAAO,CAAC,IAAI,CAAC;oBACX,UAAU;oBACV,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,UAAU,EAAE,aAAa;oBACzB,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,OAAO,CAAC,SAAS;iBAC7B,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,SAAS,CAAC,UAAkB;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACvC,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
10
|
+
import { homedir } from 'node:os';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
/**
|
|
13
|
+
* Get the path to Claude Code's settings.json.
|
|
14
|
+
* Respects CLAUDE_SETTINGS env var, defaults to ~/.claude/settings.json.
|
|
15
|
+
*/
|
|
16
|
+
function getClaudeSettingsPath() {
|
|
17
|
+
return (process.env['CLAUDE_SETTINGS'] ??
|
|
18
|
+
join(process.env['CLAUDE_HOME'] ?? join(homedir(), '.claude'), 'settings.json'));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Check if statusline integration is configured.
|
|
22
|
+
* Returns the current integration status.
|
|
23
|
+
*/
|
|
24
|
+
export function checkStatuslineIntegration() {
|
|
25
|
+
const settingsPath = getClaudeSettingsPath();
|
|
26
|
+
if (!existsSync(settingsPath))
|
|
27
|
+
return 'no_settings';
|
|
28
|
+
try {
|
|
29
|
+
const settings = JSON.parse(readFileSync(settingsPath, 'utf-8'));
|
|
30
|
+
const statusLine = settings.statusLine;
|
|
31
|
+
if (!statusLine?.type)
|
|
32
|
+
return 'not_configured';
|
|
33
|
+
if (statusLine.type !== 'command')
|
|
34
|
+
return 'custom_no_cleo';
|
|
35
|
+
const cmd = statusLine.command ?? '';
|
|
36
|
+
// Check if it's a CLEO statusline integration
|
|
37
|
+
if (cmd.includes('context-monitor.sh') ||
|
|
38
|
+
cmd.includes('cleo-statusline') ||
|
|
39
|
+
cmd.includes('.context-state.json') ||
|
|
40
|
+
cmd.includes('context-states')) {
|
|
41
|
+
return 'configured';
|
|
42
|
+
}
|
|
43
|
+
// Check if the script writes to CLEO state file
|
|
44
|
+
const scriptPath = cmd.startsWith('~') ? cmd.replace('~', homedir()) : cmd;
|
|
45
|
+
if (existsSync(scriptPath)) {
|
|
46
|
+
try {
|
|
47
|
+
const content = readFileSync(scriptPath, 'utf-8');
|
|
48
|
+
if (content.includes('context-state.json'))
|
|
49
|
+
return 'configured';
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
/* unreadable */
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return 'custom_no_cleo';
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return 'no_settings';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the statusline setup command for Claude Code settings.
|
|
63
|
+
*/
|
|
64
|
+
export function getStatuslineConfig(cleoHome) {
|
|
65
|
+
return {
|
|
66
|
+
statusLine: {
|
|
67
|
+
type: 'command',
|
|
68
|
+
command: join(cleoHome, 'lib', 'session', 'context-monitor.sh'),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get human-readable setup instructions.
|
|
74
|
+
*/
|
|
75
|
+
export function getSetupInstructions(cleoHome) {
|
|
76
|
+
const settingsPath = getClaudeSettingsPath();
|
|
77
|
+
return [
|
|
78
|
+
'To enable context monitoring, add to your Claude Code settings:',
|
|
79
|
+
`File: ${settingsPath}`,
|
|
80
|
+
'',
|
|
81
|
+
JSON.stringify(getStatuslineConfig(cleoHome), null, 2),
|
|
82
|
+
'',
|
|
83
|
+
'This enables real-time context window tracking in the CLI.',
|
|
84
|
+
].join('\n');
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=statusline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusline.js","sourceRoot":"","sources":["../../../src/providers/claude-code/statusline.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAA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B,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;gBAClD,IAAI,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;oBAAE,OAAO,YAAY,CAAC;YAClE,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,aAAa,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,OAAO;QACL,UAAU,EAAE;YACV,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,oBAAoB,CAAC;SAChE;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,MAAM,YAAY,GAAG,qBAAqB,EAAE,CAAC;IAE7C,OAAO;QACL,iEAAiE;QACjE,SAAS,YAAY,EAAE;QACvB,EAAE;QACF,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,EAAE;QACF,4DAA4D;KAC7D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 { readFile, stat } from 'node:fs/promises';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Parsing helpers
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/**
|
|
14
|
+
* Parse a CLEO task ID from TodoWrite content prefix: "[T001] ..." -> "T001".
|
|
15
|
+
*/
|
|
16
|
+
function parseTaskId(content) {
|
|
17
|
+
const match = content.match(/^\[T(\d+)\]/);
|
|
18
|
+
return match ? `T${match[1]}` : null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Strip ID and status prefixes from content to extract the clean title.
|
|
22
|
+
*/
|
|
23
|
+
function stripPrefixes(content) {
|
|
24
|
+
return content
|
|
25
|
+
.replace(/^\[T\d+\]\s*/, '')
|
|
26
|
+
.replace(/^\[!\]\s*/, '')
|
|
27
|
+
.replace(/^\[BLOCKED\]\s*/, '');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Map TodoWrite status to normalized ExternalTaskStatus.
|
|
31
|
+
*/
|
|
32
|
+
function mapStatus(twStatus) {
|
|
33
|
+
switch (twStatus) {
|
|
34
|
+
case 'completed':
|
|
35
|
+
return 'completed';
|
|
36
|
+
case 'in_progress':
|
|
37
|
+
return 'active';
|
|
38
|
+
case 'pending':
|
|
39
|
+
return 'pending';
|
|
40
|
+
default:
|
|
41
|
+
return 'pending';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the TodoWrite state file path.
|
|
46
|
+
* Claude Code writes its TodoWrite state to a known location.
|
|
47
|
+
*/
|
|
48
|
+
function getTodoWriteFilePath(projectDir) {
|
|
49
|
+
return join(projectDir, '.cleo', 'sync', 'todowrite-state.json');
|
|
50
|
+
}
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Provider implementation
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
/**
|
|
55
|
+
* Claude Code TaskSyncProvider.
|
|
56
|
+
*
|
|
57
|
+
* Reads Claude's TodoWrite JSON state, parses [T001]-prefixed task IDs
|
|
58
|
+
* and status, and returns normalized ExternalTask[].
|
|
59
|
+
*
|
|
60
|
+
* Optional: accepts a custom file path for testing.
|
|
61
|
+
*/
|
|
62
|
+
export class ClaudeCodeTaskSyncProvider {
|
|
63
|
+
customFilePath;
|
|
64
|
+
constructor(options) {
|
|
65
|
+
this.customFilePath = options?.filePath;
|
|
66
|
+
}
|
|
67
|
+
async getExternalTasks(projectDir) {
|
|
68
|
+
const filePath = this.customFilePath ?? getTodoWriteFilePath(projectDir);
|
|
69
|
+
// Check file exists
|
|
70
|
+
try {
|
|
71
|
+
await stat(filePath);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// No TodoWrite state — return empty (no tasks to sync)
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
// Parse the TodoWrite JSON
|
|
78
|
+
const raw = await readFile(filePath, 'utf-8');
|
|
79
|
+
let state;
|
|
80
|
+
try {
|
|
81
|
+
state = JSON.parse(raw);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return []; // Malformed JSON — treat as empty
|
|
85
|
+
}
|
|
86
|
+
if (!state.todos || !Array.isArray(state.todos)) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const tasks = [];
|
|
90
|
+
let syntheticIndex = 0;
|
|
91
|
+
for (const item of state.todos) {
|
|
92
|
+
const cleoTaskId = parseTaskId(item.content);
|
|
93
|
+
const title = cleoTaskId ? stripPrefixes(item.content).trim() : item.content.trim();
|
|
94
|
+
if (!title)
|
|
95
|
+
continue;
|
|
96
|
+
tasks.push({
|
|
97
|
+
externalId: cleoTaskId ?? `tw-new-${syntheticIndex++}`,
|
|
98
|
+
title,
|
|
99
|
+
status: mapStatus(item.status),
|
|
100
|
+
providerMeta: {
|
|
101
|
+
source: 'todowrite',
|
|
102
|
+
cleoTaskId,
|
|
103
|
+
activeForm: item.activeForm,
|
|
104
|
+
rawContent: item.content,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return tasks;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=task-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-sync.js","sourceRoot":"","sources":["../../../src/providers/claude-code/task-sync.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAkBjC,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;GAEG;AACH,SAAS,WAAW,CAAC,OAAe;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,OAAO;SACX,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,QAAiC;IAClD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,WAAW,CAAC;QACrB,KAAK,aAAa;YAChB,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,oBAAoB,CAAC,UAAkB;IAC9C,OAAO,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;AACnE,CAAC;AAED,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,OAAO,0B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AI,CAAC;gBACT,UAAU,EAAE,UAAU,IAAI,UAAU,cAAc,EAAE,EAAE;gBACtD,KAAK;gBACL,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC9B,YAAY,EAAE;oBACZ,MAAM,EAAE,WAAW;oBACnB,UAAU;oBACV,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,UAAU,EAAE,IAAI,CAAC,OAAO;iBACzB;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export class ClaudeCodeTransportProvider {
|
|
10
|
+
transportName = 'claude-code';
|
|
11
|
+
createTransport() {
|
|
12
|
+
// Returns null — actual transport creation is handled by the signaldock factory
|
|
13
|
+
// which checks for this adapter's transport capability.
|
|
14
|
+
// Full wiring will be completed in Phase 5.
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/providers/claude-code/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,OAAO,2BAA2B;IAC7B,aAAa,GAAG,aAAa,CAAC;IAEvC,eAAe;QACb,gFAAgF;QAChF,wDAAwD;QACxD,4CAA4C;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor Adapter
|
|
3
|
+
*
|
|
4
|
+
* 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: Registers MCP server in .cursor/mcp.json and manages 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
|
+
export class CursorAdapter {
|
|
24
|
+
id = 'cursor';
|
|
25
|
+
name = 'Cursor';
|
|
26
|
+
version = '1.0.0';
|
|
27
|
+
capabilities = {
|
|
28
|
+
supportsHooks: false,
|
|
29
|
+
supportedHookEvents: [],
|
|
30
|
+
supportsSpawn: false,
|
|
31
|
+
supportsInstall: true,
|
|
32
|
+
supportsMcp: true,
|
|
33
|
+
supportsInstructionFiles: true,
|
|
34
|
+
instructionFilePattern: '.cursor/rules/*.mdc',
|
|
35
|
+
supportsContextMonitor: false,
|
|
36
|
+
supportsStatusline: false,
|
|
37
|
+
supportsProviderPaths: true,
|
|
38
|
+
supportsTransport: false,
|
|
39
|
+
supportsTaskSync: false,
|
|
40
|
+
};
|
|
41
|
+
hooks;
|
|
42
|
+
install;
|
|
43
|
+
projectDir = null;
|
|
44
|
+
initialized = false;
|
|
45
|
+
constructor() {
|
|
46
|
+
this.hooks = new CursorHookProvider();
|
|
47
|
+
this.install = new CursorInstallProvider();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Initialize the adapter for a given project directory.
|
|
51
|
+
*
|
|
52
|
+
* @param projectDir - Root directory of the project
|
|
53
|
+
*/
|
|
54
|
+
async initialize(projectDir) {
|
|
55
|
+
this.projectDir = projectDir;
|
|
56
|
+
this.initialized = true;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Dispose the adapter and clean up resources.
|
|
60
|
+
*/
|
|
61
|
+
async dispose() {
|
|
62
|
+
if (this.hooks.isRegistered()) {
|
|
63
|
+
await this.hooks.unregisterNativeHooks();
|
|
64
|
+
}
|
|
65
|
+
this.initialized = false;
|
|
66
|
+
this.projectDir = null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Run a health check to verify Cursor is accessible.
|
|
70
|
+
*
|
|
71
|
+
* Checks:
|
|
72
|
+
* 1. Adapter has been initialized
|
|
73
|
+
* 2. .cursor/ configuration directory exists in the project
|
|
74
|
+
* 3. CURSOR_EDITOR env var is set
|
|
75
|
+
*
|
|
76
|
+
* @returns Health status with details about each check
|
|
77
|
+
*/
|
|
78
|
+
async healthCheck() {
|
|
79
|
+
const details = {};
|
|
80
|
+
if (!this.initialized) {
|
|
81
|
+
return {
|
|
82
|
+
healthy: false,
|
|
83
|
+
provider: this.id,
|
|
84
|
+
details: { error: 'Adapter not initialized' },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// Check for Cursor config directory in the project
|
|
88
|
+
let configExists = false;
|
|
89
|
+
if (this.projectDir) {
|
|
90
|
+
const cursorConfigDir = join(this.projectDir, '.cursor');
|
|
91
|
+
configExists = existsSync(cursorConfigDir);
|
|
92
|
+
details.configDirExists = configExists;
|
|
93
|
+
}
|
|
94
|
+
// Check for CURSOR_EDITOR env var
|
|
95
|
+
const editorEnvSet = process.env.CURSOR_EDITOR !== undefined;
|
|
96
|
+
details.editorEnvSet = editorEnvSet;
|
|
97
|
+
// Check for legacy .cursorrules file
|
|
98
|
+
if (this.projectDir) {
|
|
99
|
+
const legacyRulesExist = existsSync(join(this.projectDir, '.cursorrules'));
|
|
100
|
+
details.legacyRulesExist = legacyRulesExist;
|
|
101
|
+
}
|
|
102
|
+
// Healthy if we detect Cursor presence (config dir or env var)
|
|
103
|
+
const healthy = configExists || editorEnvSet;
|
|
104
|
+
details.detected = healthy;
|
|
105
|
+
return {
|
|
106
|
+
healthy,
|
|
107
|
+
provider: this.id,
|
|
108
|
+
details,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Check whether the adapter has been initialized.
|
|
113
|
+
*/
|
|
114
|
+
isInitialized() {
|
|
115
|
+
return this.initialized;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the project directory this adapter was initialized with.
|
|
119
|
+
*/
|
|
120
|
+
getProjectDir() {
|
|
121
|
+
return this.projectDir;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# 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;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IACf,EAAE,GAAG,QAAQ,CAAC;IACd,IAAI,GAAG,QAAQ,CAAC;IAChB,OAAO,GAAG,OAAO,CAAC;IAE3B,YAAY,GAAwB;QAClC,aAAa,EAAE,KAAK;QACpB,mBAAmB,EAAE,EAAE;QACvB,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,IAAI;QACrB,WAAW,EAAE,IAAI;QACjB,wBAAwB,EAAE,IAAI;QAC9B,sBAAsB,EAAE,qBAAqB;QAC7C,sBAAsB,EAAE,K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G,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,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor Hook Provider
|
|
3
|
+
*
|
|
4
|
+
* Cursor does not have a native hook/event system for external tools.
|
|
5
|
+
* This provider returns null for all event mappings and marks hooks
|
|
6
|
+
* as unsupported. It exists to satisfy the AdapterHookProvider contract
|
|
7
|
+
* so the adapter can be used uniformly by the AdapterManager.
|
|
8
|
+
*
|
|
9
|
+
* @task T5240
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Hook provider for Cursor (stub).
|
|
13
|
+
*
|
|
14
|
+
* Cursor lacks a hook-based lifecycle event system. All mapping
|
|
15
|
+
* operations return null. Registration is a no-op.
|
|
16
|
+
*/
|
|
17
|
+
export class CursorHookProvider {
|
|
18
|
+
registered = false;
|
|
19
|
+
/**
|
|
20
|
+
* Map a provider event name to a CAAMP hook event name.
|
|
21
|
+
*
|
|
22
|
+
* Always returns null since Cursor does not emit hook events.
|
|
23
|
+
*
|
|
24
|
+
* @param _providerEvent - Ignored; Cursor has no hook events
|
|
25
|
+
* @returns null (no mapping available)
|
|
26
|
+
*/
|
|
27
|
+
mapProviderEvent(_providerEvent) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Register native hooks for a project.
|
|
32
|
+
*
|
|
33
|
+
* No-op for Cursor since it has no hook system.
|
|
34
|
+
*
|
|
35
|
+
* @param _projectDir - Ignored
|
|
36
|
+
*/
|
|
37
|
+
async registerNativeHooks(_projectDir) {
|
|
38
|
+
this.registered = true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Unregister native hooks.
|
|
42
|
+
*
|
|
43
|
+
* No-op for Cursor since it has no hook system.
|
|
44
|
+
*/
|
|
45
|
+
async unregisterNativeHooks() {
|
|
46
|
+
this.registered = false;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check whether hooks have been registered.
|
|
50
|
+
*/
|
|
51
|
+
isRegistered() {
|
|
52
|
+
return this.registered;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/providers/cursor/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IACrB,UAAU,GAAG,KAAK,CAAC;IAE3B;;;;;;;OAOG;IACH,gBAAgB,CAAC,cAAsB;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB,CAAC,WAAmB;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,qBAAqB;QACzB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor provider adapter.
|
|
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
|
+
export function createAdapter() {
|
|
19
|
+
return new CursorAdapter();
|
|
20
|
+
}
|
|
21
|
+
//# 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;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC"}
|