stigmergy 1.0.57
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/LICENSE +19 -0
- package/README.de.md +301 -0
- package/README.en.md +301 -0
- package/README.es.md +301 -0
- package/README.fr.md +301 -0
- package/README.ja.md +301 -0
- package/README.ko.md +301 -0
- package/README.md +301 -0
- package/README.ru.md +301 -0
- package/README.zh.md +301 -0
- package/package.json +82 -0
- package/src/adapters/claude/__init__.py +13 -0
- package/src/adapters/claude/claude_skills_integration.py +609 -0
- package/src/adapters/claude/hook_adapter.py +663 -0
- package/src/adapters/claude/install_claude_integration.py +265 -0
- package/src/adapters/claude/skills_hook_adapter.py +841 -0
- package/src/adapters/claude/standalone_claude_adapter.py +384 -0
- package/src/adapters/cline/__init__.py +20 -0
- package/src/adapters/cline/config.py +108 -0
- package/src/adapters/cline/install_cline_integration.py +617 -0
- package/src/adapters/cline/mcp_server.py +713 -0
- package/src/adapters/cline/standalone_cline_adapter.py +459 -0
- package/src/adapters/codebuddy/__init__.py +13 -0
- package/src/adapters/codebuddy/buddy_adapter.py +1125 -0
- package/src/adapters/codebuddy/install_codebuddy_integration.py +279 -0
- package/src/adapters/codebuddy/skills_hook_adapter.py +672 -0
- package/src/adapters/codebuddy/skills_integration.py +395 -0
- package/src/adapters/codebuddy/standalone_codebuddy_adapter.py +403 -0
- package/src/adapters/codex/__init__.py +11 -0
- package/src/adapters/codex/base.py +46 -0
- package/src/adapters/codex/install_codex_integration.py +311 -0
- package/src/adapters/codex/mcp_server.py +493 -0
- package/src/adapters/codex/natural_language_parser.py +82 -0
- package/src/adapters/codex/slash_command_adapter.py +326 -0
- package/src/adapters/codex/standalone_codex_adapter.py +362 -0
- package/src/adapters/copilot/__init__.py +13 -0
- package/src/adapters/copilot/install_copilot_integration.py +564 -0
- package/src/adapters/copilot/mcp_adapter.py +772 -0
- package/src/adapters/copilot/mcp_server.py +168 -0
- package/src/adapters/copilot/standalone_copilot_adapter.py +114 -0
- package/src/adapters/gemini/__init__.py +13 -0
- package/src/adapters/gemini/extension_adapter.py +690 -0
- package/src/adapters/gemini/install_gemini_integration.py +257 -0
- package/src/adapters/gemini/standalone_gemini_adapter.py +366 -0
- package/src/adapters/iflow/__init__.py +7 -0
- package/src/adapters/iflow/hook_adapter.py +1038 -0
- package/src/adapters/iflow/hook_installer.py +536 -0
- package/src/adapters/iflow/install_iflow_integration.py +271 -0
- package/src/adapters/iflow/official_hook_adapter.py +1272 -0
- package/src/adapters/iflow/standalone_iflow_adapter.py +48 -0
- package/src/adapters/iflow/workflow_adapter.py +793 -0
- package/src/adapters/qoder/hook_installer.py +732 -0
- package/src/adapters/qoder/install_qoder_integration.py +265 -0
- package/src/adapters/qoder/notification_hook_adapter.py +863 -0
- package/src/adapters/qoder/standalone_qoder_adapter.py +48 -0
- package/src/adapters/qwen/__init__.py +17 -0
- package/src/adapters/qwencode/__init__.py +13 -0
- package/src/adapters/qwencode/inheritance_adapter.py +818 -0
- package/src/adapters/qwencode/install_qwencode_integration.py +276 -0
- package/src/adapters/qwencode/standalone_qwencode_adapter.py +399 -0
- package/src/atomic_collaboration_handler.py +461 -0
- package/src/cli_collaboration_agent.py +697 -0
- package/src/collaboration/hooks.py +315 -0
- package/src/core/__init__.py +21 -0
- package/src/core/ai_environment_scanner.py +331 -0
- package/src/core/base_adapter.py +220 -0
- package/src/core/cli_hook_integration.py +406 -0
- package/src/core/cross_cli_executor.py +713 -0
- package/src/core/cross_cli_mapping.py +1163 -0
- package/src/core/cross_platform_encoding.py +365 -0
- package/src/core/cross_platform_safe_cli.py +894 -0
- package/src/core/direct_cli_executor.py +805 -0
- package/src/core/direct_cli_hook_system.py +958 -0
- package/src/core/enhanced_init_processor.py +427 -0
- package/src/core/graceful_cli_executor.py +912 -0
- package/src/core/md_enhancer.py +342 -0
- package/src/core/md_generator.py +619 -0
- package/src/core/models.py +218 -0
- package/src/core/parser.py +108 -0
- package/src/core/real_cli_hook_system.py +852 -0
- package/src/core/real_cross_cli_system.py +925 -0
- package/src/core/verified_cross_cli_system.py +961 -0
- package/src/deploy.js +737 -0
- package/src/enhanced_deploy.js +303 -0
- package/src/enhanced_universal_cli_setup.py +930 -0
- package/src/kimi_wrapper.py +104 -0
- package/src/main.js +1309 -0
- package/src/shell_integration.py +398 -0
- package/src/simple-main.js +315 -0
- package/src/smart_router_creator.py +323 -0
- package/src/universal_cli_setup.py +1289 -0
- package/src/utils/__init__.py +12 -0
- package/src/utils/cli_detector.py +445 -0
- package/src/utils/file_utils.py +246 -0
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Standalone Cline CLI Adapter for Stigmergy System
|
|
4
|
+
|
|
5
|
+
This adapter provides integration between Cline CLI and the Stigmergy multi-CLI collaboration system.
|
|
6
|
+
Implements hook-based integration with cross-CLI delegation capabilities.
|
|
7
|
+
|
|
8
|
+
Based on Cline's gRPC architecture and hook system for seamless integration.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
import re
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
from datetime import datetime
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Dict, Any, Optional, List, Tuple
|
|
19
|
+
|
|
20
|
+
# Add parent directory to path for imports
|
|
21
|
+
sys.path.append(str(Path(__file__).parent.parent.parent))
|
|
22
|
+
|
|
23
|
+
from core.base_adapter import BaseCrossCLIAdapter
|
|
24
|
+
from core.cross_platform_safe_cli import CrossPlatformSafeCLI
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class StandaloneClineAdapter(BaseCrossCLIAdapter):
|
|
28
|
+
"""
|
|
29
|
+
Cline CLI adapter implementing hook-based integration with cross-CLI capabilities.
|
|
30
|
+
|
|
31
|
+
Features:
|
|
32
|
+
- Task lifecycle hook integration
|
|
33
|
+
- Cross-CLI delegation and collaboration
|
|
34
|
+
- JSON-based communication protocol
|
|
35
|
+
- Multi-agent orchestration support
|
|
36
|
+
- Comprehensive error handling and statistics
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
def __init__(self):
|
|
40
|
+
super().__init__("cline")
|
|
41
|
+
self.display_name = "Cline CLI"
|
|
42
|
+
self.integration_type = "hook_system"
|
|
43
|
+
|
|
44
|
+
# Cross-CLI collaboration patterns
|
|
45
|
+
self.chinese_patterns = [
|
|
46
|
+
r'请用(\w+)\s*帮我?([^。!?\n]*)',
|
|
47
|
+
r'调用(\w+)\s*来([^。!?\n]*)',
|
|
48
|
+
r'用(\w+)\s*帮我?([^。!?\n]*)',
|
|
49
|
+
r'让(\w+)\s*([^。!?\n]*)',
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
self.english_patterns = [
|
|
53
|
+
r'use\s+(\w+)\s+to\s+([^\.\n!?]*)',
|
|
54
|
+
r'call\s+(\w+)\s+to\s+([^\.\n!?]*)',
|
|
55
|
+
r'ask\s+(\w+)\s+for\s+([^\.\n!?]*)',
|
|
56
|
+
r'let\s+(\w+)\s+([^\.\n!?]*)',
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
# Statistics tracking
|
|
60
|
+
self.stats = {
|
|
61
|
+
'total_requests': 0,
|
|
62
|
+
'cross_cli_calls': 0,
|
|
63
|
+
'successful_calls': 0,
|
|
64
|
+
'failed_calls': 0,
|
|
65
|
+
'start_time': datetime.now()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
# Hook configuration
|
|
69
|
+
self.hook_config = {
|
|
70
|
+
'hook_directory': Path.home() / 'Documents' / 'Cline' / 'Rules' / 'hooks',
|
|
71
|
+
'project_hook_directory': '.clinerules/hooks',
|
|
72
|
+
'supported_hooks': [
|
|
73
|
+
'TaskStart', 'TaskResume', 'TaskCancel',
|
|
74
|
+
'UserPromptSubmit', 'PreToolUse', 'PostToolUse'
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# Initialize safe CLI executor
|
|
79
|
+
self.safe_cli = CrossPlatformSafeCLI()
|
|
80
|
+
|
|
81
|
+
def is_available(self) -> bool:
|
|
82
|
+
"""Check if Cline CLI is available and properly configured."""
|
|
83
|
+
try:
|
|
84
|
+
result = subprocess.run(
|
|
85
|
+
['cline', '--version'],
|
|
86
|
+
capture_output=True,
|
|
87
|
+
text=True,
|
|
88
|
+
timeout=10
|
|
89
|
+
)
|
|
90
|
+
return result.returncode == 0
|
|
91
|
+
except (subprocess.TimeoutExpired, FileNotFoundError, subprocess.SubprocessError):
|
|
92
|
+
return False
|
|
93
|
+
|
|
94
|
+
def initialize(self) -> bool:
|
|
95
|
+
"""Initialize the Cline CLI adapter and setup hooks."""
|
|
96
|
+
try:
|
|
97
|
+
if not self.is_available():
|
|
98
|
+
return False
|
|
99
|
+
|
|
100
|
+
# Create hook directories if they don't exist
|
|
101
|
+
self._setup_hook_directories()
|
|
102
|
+
|
|
103
|
+
# Install Stigmergy-specific hooks
|
|
104
|
+
self._install_stigmergy_hooks()
|
|
105
|
+
|
|
106
|
+
return True
|
|
107
|
+
except Exception as e:
|
|
108
|
+
self._log_error(f"Failed to initialize Cline adapter: {e}")
|
|
109
|
+
return False
|
|
110
|
+
|
|
111
|
+
def execute_task(self, task: str, context: Dict[str, Any]) -> str:
|
|
112
|
+
"""
|
|
113
|
+
Execute a task using Cline CLI with cross-CLI collaboration support.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
task: The task description or command
|
|
117
|
+
context: Additional context information
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
Task execution result
|
|
121
|
+
"""
|
|
122
|
+
self.stats['total_requests'] += 1
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
# Check for cross-CLI collaboration requests
|
|
126
|
+
cross_cli_result = self._handle_cross_cli_collaboration(task, context)
|
|
127
|
+
if cross_cli_result:
|
|
128
|
+
return cross_cli_result
|
|
129
|
+
|
|
130
|
+
# Execute task with Cline CLI
|
|
131
|
+
return self._execute_cline_task(task, context)
|
|
132
|
+
|
|
133
|
+
except Exception as e:
|
|
134
|
+
self.stats['failed_calls'] += 1
|
|
135
|
+
error_msg = f"Error executing Cline task: {str(e)}"
|
|
136
|
+
self._log_error(error_msg)
|
|
137
|
+
return self._format_error_result(error_msg)
|
|
138
|
+
|
|
139
|
+
def health_check(self) -> Dict[str, Any]:
|
|
140
|
+
"""Perform comprehensive health check of Cline CLI integration."""
|
|
141
|
+
health_status = {
|
|
142
|
+
'adapter_name': self.cli_name,
|
|
143
|
+
'display_name': self.display_name,
|
|
144
|
+
'version': self.version,
|
|
145
|
+
'integration_type': self.integration_type,
|
|
146
|
+
'available': self.is_available(),
|
|
147
|
+
'initialized': False,
|
|
148
|
+
'hooks_configured': False,
|
|
149
|
+
'statistics': self.stats.copy(),
|
|
150
|
+
'platform_support': self._check_platform_support(),
|
|
151
|
+
'errors': []
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
if health_status['available']:
|
|
156
|
+
health_status['initialized'] = self.initialize()
|
|
157
|
+
health_status['hooks_configured'] = self._verify_hooks_configured()
|
|
158
|
+
|
|
159
|
+
# Get Cline version info
|
|
160
|
+
version_result = subprocess.run(
|
|
161
|
+
['cline', '--version'],
|
|
162
|
+
capture_output=True,
|
|
163
|
+
text=True,
|
|
164
|
+
timeout=5
|
|
165
|
+
)
|
|
166
|
+
if version_result.returncode == 0:
|
|
167
|
+
health_status['cline_version'] = version_result.stdout.strip()
|
|
168
|
+
|
|
169
|
+
except Exception as e:
|
|
170
|
+
health_status['errors'].append(str(e))
|
|
171
|
+
|
|
172
|
+
return health_status
|
|
173
|
+
|
|
174
|
+
def _setup_hook_directories(self):
|
|
175
|
+
"""Create necessary hook directories for Cline integration."""
|
|
176
|
+
try:
|
|
177
|
+
# Create global hook directory
|
|
178
|
+
self.hook_config['hook_directory'].mkdir(parents=True, exist_ok=True)
|
|
179
|
+
|
|
180
|
+
# Create project-specific hook directory
|
|
181
|
+
project_hook_dir = Path.cwd() / self.hook_config['project_hook_directory']
|
|
182
|
+
project_hook_dir.mkdir(parents=True, exist_ok=True)
|
|
183
|
+
|
|
184
|
+
except Exception as e:
|
|
185
|
+
self._log_error(f"Failed to setup hook directories: {e}")
|
|
186
|
+
|
|
187
|
+
def _install_stigmergy_hooks(self):
|
|
188
|
+
"""Install Stigmergy-specific hooks for Cline integration."""
|
|
189
|
+
try:
|
|
190
|
+
for hook_name in self.hook_config['supported_hooks']:
|
|
191
|
+
self._create_hook_file(hook_name)
|
|
192
|
+
except Exception as e:
|
|
193
|
+
self._log_error(f"Failed to install Stigmergy hooks: {e}")
|
|
194
|
+
|
|
195
|
+
def _create_hook_file(self, hook_name: str):
|
|
196
|
+
"""Create a specific hook file for Cline integration."""
|
|
197
|
+
hook_content = self._generate_hook_script(hook_name)
|
|
198
|
+
|
|
199
|
+
# Create in global hooks directory
|
|
200
|
+
global_hook_path = self.hook_config['hook_directory'] / hook_name
|
|
201
|
+
global_hook_path.write_text(hook_content)
|
|
202
|
+
global_hook_path.chmod(0o755)
|
|
203
|
+
|
|
204
|
+
# Create in project hooks directory
|
|
205
|
+
project_hook_path = Path.cwd() / self.hook_config['project_hook_directory'] / hook_name
|
|
206
|
+
project_hook_path.write_text(hook_content)
|
|
207
|
+
project_hook_path.chmod(0o755)
|
|
208
|
+
|
|
209
|
+
def _generate_hook_script(self, hook_name: str) -> str:
|
|
210
|
+
"""Generate hook script content for Stigmergy integration."""
|
|
211
|
+
return f'''#!/usr/bin/env python3
|
|
212
|
+
"""
|
|
213
|
+
Stigmergy Integration Hook for Cline - {hook_name}
|
|
214
|
+
This hook enables cross-CLI collaboration and task tracking.
|
|
215
|
+
"""
|
|
216
|
+
|
|
217
|
+
import json
|
|
218
|
+
import sys
|
|
219
|
+
import os
|
|
220
|
+
from datetime import datetime
|
|
221
|
+
|
|
222
|
+
def main():
|
|
223
|
+
try:
|
|
224
|
+
# Read JSON input from stdin
|
|
225
|
+
input_data = json.loads(sys.stdin.read())
|
|
226
|
+
|
|
227
|
+
# Log hook execution for Stigmergy tracking
|
|
228
|
+
log_entry = {{
|
|
229
|
+
'hook_name': '{hook_name}',
|
|
230
|
+
'timestamp': datetime.now().isoformat(),
|
|
231
|
+
'input_data': input_data,
|
|
232
|
+
'cline_version': input_data.get('clineVersion', 'unknown'),
|
|
233
|
+
'task_id': input_data.get('taskId', 'unknown')
|
|
234
|
+
}}
|
|
235
|
+
|
|
236
|
+
# Write to Stigmergy log (if available)
|
|
237
|
+
log_path = os.path.expanduser('~/.stigmergy/logs/cline_hooks.log')
|
|
238
|
+
os.makedirs(os.path.dirname(log_path), exist_ok=True)
|
|
239
|
+
|
|
240
|
+
with open(log_path, 'a', encoding='utf-8') as f:
|
|
241
|
+
f.write(json.dumps(log_entry) + '\n')
|
|
242
|
+
|
|
243
|
+
# Return neutral response (don't interfere with Cline operations)
|
|
244
|
+
response = {{
|
|
245
|
+
"cancel": False,
|
|
246
|
+
"contextModification": ""
|
|
247
|
+
}}
|
|
248
|
+
|
|
249
|
+
print(json.dumps(response))
|
|
250
|
+
|
|
251
|
+
except Exception as e:
|
|
252
|
+
# On error, still allow Cline to continue
|
|
253
|
+
response = {{
|
|
254
|
+
"cancel": False,
|
|
255
|
+
"contextModification": f"Hook error: {{str(e)}}"
|
|
256
|
+
}}
|
|
257
|
+
print(json.dumps(response))
|
|
258
|
+
|
|
259
|
+
if __name__ == '__main__':
|
|
260
|
+
main()
|
|
261
|
+
'''
|
|
262
|
+
|
|
263
|
+
def _handle_cross_cli_collaboration(self, task: str, context: Dict[str, Any]) -> Optional[str]:
|
|
264
|
+
"""Handle cross-CLI collaboration requests."""
|
|
265
|
+
# Check for Chinese collaboration patterns
|
|
266
|
+
for pattern in self.chinese_patterns:
|
|
267
|
+
match = re.search(pattern, task)
|
|
268
|
+
if match:
|
|
269
|
+
target_cli = match.group(1).lower()
|
|
270
|
+
sub_task = match.group(2).strip()
|
|
271
|
+
|
|
272
|
+
if target_cli != self.cli_name and self._is_supported_cli(target_cli):
|
|
273
|
+
return self._delegate_to_cli(target_cli, sub_task, context)
|
|
274
|
+
|
|
275
|
+
# Check for English collaboration patterns
|
|
276
|
+
for pattern in self.english_patterns:
|
|
277
|
+
match = re.search(pattern, task)
|
|
278
|
+
if match:
|
|
279
|
+
target_cli = match.group(1).lower()
|
|
280
|
+
sub_task = match.group(2).strip()
|
|
281
|
+
|
|
282
|
+
if target_cli != self.cli_name and self._is_supported_cli(target_cli):
|
|
283
|
+
return self._delegate_to_cli(target_cli, sub_task, context)
|
|
284
|
+
|
|
285
|
+
return None
|
|
286
|
+
|
|
287
|
+
def _is_supported_cli(self, cli_name: str) -> bool:
|
|
288
|
+
"""Check if a CLI tool is supported by Stigmergy."""
|
|
289
|
+
supported_clis = [
|
|
290
|
+
'claude', 'gemini', 'qwen', 'codebuddy', 'copilot',
|
|
291
|
+
'codex', 'iflow', 'qoder', 'qwencode', 'cline'
|
|
292
|
+
]
|
|
293
|
+
return cli_name in supported_clis
|
|
294
|
+
|
|
295
|
+
def _delegate_to_cli(self, target_cli: str, task: str, context: Dict[str, Any]) -> str:
|
|
296
|
+
"""Delegate task to another CLI tool."""
|
|
297
|
+
self.stats['cross_cli_calls'] += 1
|
|
298
|
+
|
|
299
|
+
try:
|
|
300
|
+
# Use the safe CLI executor for cross-CLI calls
|
|
301
|
+
result = self.safe_cli.execute_cross_cli_call(target_cli, task, context)
|
|
302
|
+
self.stats['successful_calls'] += 1
|
|
303
|
+
|
|
304
|
+
return self._format_cross_cli_result(target_cli, task, result)
|
|
305
|
+
|
|
306
|
+
except Exception as e:
|
|
307
|
+
self.stats['failed_calls'] += 1
|
|
308
|
+
error_msg = f"Failed to delegate to {target_cli}: {str(e)}"
|
|
309
|
+
self._log_error(error_msg)
|
|
310
|
+
return self._format_error_result(error_msg)
|
|
311
|
+
|
|
312
|
+
def _execute_cline_task(self, task: str, context: Dict[str, Any]) -> str:
|
|
313
|
+
"""Execute task using Cline CLI directly."""
|
|
314
|
+
try:
|
|
315
|
+
# Prepare Cline command
|
|
316
|
+
cline_cmd = ['cline', 'execute', '--task', task]
|
|
317
|
+
|
|
318
|
+
# Add context parameters if available
|
|
319
|
+
if context:
|
|
320
|
+
context_json = json.dumps(context)
|
|
321
|
+
cline_cmd.extend(['--context', context_json])
|
|
322
|
+
|
|
323
|
+
# Execute Cline command
|
|
324
|
+
result = subprocess.run(
|
|
325
|
+
cline_cmd,
|
|
326
|
+
capture_output=True,
|
|
327
|
+
text=True,
|
|
328
|
+
timeout=300 # 5 minute timeout
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
if result.returncode == 0:
|
|
332
|
+
self.stats['successful_calls'] += 1
|
|
333
|
+
return self._format_success_result(task, result.stdout)
|
|
334
|
+
else:
|
|
335
|
+
self.stats['failed_calls'] += 1
|
|
336
|
+
error_msg = f"Cline execution failed: {result.stderr}"
|
|
337
|
+
return self._format_error_result(error_msg)
|
|
338
|
+
|
|
339
|
+
except subprocess.TimeoutExpired:
|
|
340
|
+
self.stats['failed_calls'] += 1
|
|
341
|
+
return self._format_error_result("Cline execution timed out")
|
|
342
|
+
except Exception as e:
|
|
343
|
+
self.stats['failed_calls'] += 1
|
|
344
|
+
error_msg = f"Cline execution error: {str(e)}"
|
|
345
|
+
return self._format_error_result(error_msg)
|
|
346
|
+
|
|
347
|
+
def _verify_hooks_configured(self) -> bool:
|
|
348
|
+
"""Verify that Stigmergy hooks are properly configured."""
|
|
349
|
+
try:
|
|
350
|
+
required_hooks = self.hook_config['supported_hooks']
|
|
351
|
+
hook_dir = self.hook_config['hook_directory']
|
|
352
|
+
|
|
353
|
+
for hook_name in required_hooks:
|
|
354
|
+
hook_path = hook_dir / hook_name
|
|
355
|
+
if not hook_path.exists() or not hook_path.is_file():
|
|
356
|
+
return False
|
|
357
|
+
|
|
358
|
+
return True
|
|
359
|
+
except Exception:
|
|
360
|
+
return False
|
|
361
|
+
|
|
362
|
+
def _check_platform_support(self) -> Dict[str, Any]:
|
|
363
|
+
"""Check platform support status for Cline CLI."""
|
|
364
|
+
import platform
|
|
365
|
+
current_platform = platform.system().lower()
|
|
366
|
+
|
|
367
|
+
support_status = {
|
|
368
|
+
'current_platform': current_platform,
|
|
369
|
+
'supported': current_platform in ['darwin', 'linux'],
|
|
370
|
+
'windows_support': 'planned'
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return support_status
|
|
374
|
+
|
|
375
|
+
def _format_cross_cli_result(self, target_cli: str, task: str, result: str) -> str:
|
|
376
|
+
"""Format cross-CLI collaboration result."""
|
|
377
|
+
return f"""## 🔗 跨CLI调用结果
|
|
378
|
+
|
|
379
|
+
**源工具**: {self.display_name.upper()} ({self.integration_type})
|
|
380
|
+
**目标工具**: {target_cli.upper()}
|
|
381
|
+
**任务**: {task}
|
|
382
|
+
**执行时间**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
{result}
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
*{self.integration_type}系统原生集成 - 无抽象层*"""
|
|
391
|
+
|
|
392
|
+
def _format_success_result(self, task: str, output: str) -> str:
|
|
393
|
+
"""Format successful Cline execution result."""
|
|
394
|
+
return f"""## ✅ Cline CLI 执行结果
|
|
395
|
+
|
|
396
|
+
**任务**: {task}
|
|
397
|
+
**状态**: 成功
|
|
398
|
+
**执行时间**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
{output}
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
*Cline v{self.version} - Hook系统集成*"""
|
|
407
|
+
|
|
408
|
+
def _format_error_result(self, error_msg: str) -> str:
|
|
409
|
+
"""Format error result."""
|
|
410
|
+
return f"""## ❌ Cline CLI 执行错误
|
|
411
|
+
|
|
412
|
+
**错误信息**: {error_msg}
|
|
413
|
+
**发生时间**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
**统计信息**:
|
|
418
|
+
- 总请求数: {self.stats['total_requests']}
|
|
419
|
+
- 成功调用: {self.stats['successful_calls']}
|
|
420
|
+
- 失败调用: {self.stats['failed_calls']}
|
|
421
|
+
- 跨CLI调用: {self.stats['cross_cli_calls']}
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
*请检查Cline CLI配置和系统环境*"""
|
|
426
|
+
|
|
427
|
+
def _log_error(self, error_msg: str):
|
|
428
|
+
"""Log error to Stigmergy error log."""
|
|
429
|
+
try:
|
|
430
|
+
log_path = Path.home() / '.stigmergy' / 'logs' / 'cline_errors.log'
|
|
431
|
+
log_path.parent.mkdir(parents=True, exist_ok=True)
|
|
432
|
+
|
|
433
|
+
with open(log_path, 'a', encoding='utf-8') as f:
|
|
434
|
+
f.write(f"[{datetime.now().isoformat()}] {error_msg}\n")
|
|
435
|
+
except Exception:
|
|
436
|
+
pass # Silent fail for logging errors
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
def main():
|
|
440
|
+
"""Main function for standalone testing."""
|
|
441
|
+
adapter = StandaloneClineAdapter()
|
|
442
|
+
|
|
443
|
+
if not adapter.is_available():
|
|
444
|
+
print("Cline CLI is not available. Please install Cline CLI first.")
|
|
445
|
+
return 1
|
|
446
|
+
|
|
447
|
+
if not adapter.initialize():
|
|
448
|
+
print("Failed to initialize Cline adapter.")
|
|
449
|
+
return 1
|
|
450
|
+
|
|
451
|
+
# Test basic functionality
|
|
452
|
+
health = adapter.health_check()
|
|
453
|
+
print(f"Cline Adapter Health: {json.dumps(health, indent=2, ensure_ascii=False)}")
|
|
454
|
+
|
|
455
|
+
return 0
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
if __name__ == '__main__':
|
|
459
|
+
sys.exit(main())
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CodeBuddy CLI 适配器包
|
|
3
|
+
|
|
4
|
+
基于 CodeBuddy CLI 官方 Skills Hook 系统的原生集成
|
|
5
|
+
完全无抽象层设计
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .standalone_codebuddy_adapter import get_standalone_codebuddy_adapter, StandaloneCodeBuddyAdapter
|
|
9
|
+
|
|
10
|
+
# 向后兼容的别名
|
|
11
|
+
CodeBuddySkillsHookAdapter = StandaloneCodeBuddyAdapter
|
|
12
|
+
|
|
13
|
+
__all__ = ['StandaloneCodeBuddyAdapter', 'get_standalone_codebuddy_adapter', 'CodeBuddySkillsHookAdapter']
|