stigmergy 1.0.68 → 1.0.70
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/README.en.md +306 -300
- package/README.md +469 -301
- package/package.json +97 -81
- package/scripts/publish.js +268 -0
- package/scripts/simple-publish.js +59 -0
- package/src/index.js +12 -0
- package/test/enhanced-main-alignment.test.js +298 -0
- package/test/hook-system-integration-test.js +307 -0
- package/test/natural-language-skills-test.js +320 -0
- package/test/nl-integration-test.js +179 -0
- package/test/parameter-parsing-test.js +143 -0
- package/test/real-test.js +435 -0
- package/test/system-compatibility-test.js +447 -0
- package/test/tdd-fixes-test.js +211 -0
- package/test/third-party-skills-test.js +321 -0
- package/test/tool-selection-integration-test.js +157 -0
- package/test/unit/cli-scanner.test.js +291 -0
- package/test/unit/cross-cli-executor.test.js +399 -0
- package/src/adapters/claude/__init__.py +0 -13
- package/src/adapters/claude/claude_skills_integration.py +0 -609
- package/src/adapters/claude/hook_adapter.py +0 -663
- package/src/adapters/claude/install_claude_integration.py +0 -265
- package/src/adapters/claude/skills_hook_adapter.py +0 -841
- package/src/adapters/claude/standalone_claude_adapter.py +0 -384
- package/src/adapters/cline/__init__.py +0 -20
- package/src/adapters/cline/config.py +0 -108
- package/src/adapters/cline/install_cline_integration.py +0 -617
- package/src/adapters/cline/mcp_server.py +0 -713
- package/src/adapters/cline/standalone_cline_adapter.py +0 -459
- package/src/adapters/codebuddy/__init__.py +0 -13
- package/src/adapters/codebuddy/buddy_adapter.py +0 -1125
- package/src/adapters/codebuddy/install_codebuddy_integration.py +0 -279
- package/src/adapters/codebuddy/skills_hook_adapter.py +0 -672
- package/src/adapters/codebuddy/skills_integration.py +0 -395
- package/src/adapters/codebuddy/standalone_codebuddy_adapter.py +0 -403
- package/src/adapters/codex/__init__.py +0 -11
- package/src/adapters/codex/base.py +0 -46
- package/src/adapters/codex/install_codex_integration.py +0 -311
- package/src/adapters/codex/mcp_server.py +0 -493
- package/src/adapters/codex/natural_language_parser.py +0 -82
- package/src/adapters/codex/slash_command_adapter.py +0 -326
- package/src/adapters/codex/standalone_codex_adapter.py +0 -362
- package/src/adapters/copilot/__init__.py +0 -13
- package/src/adapters/copilot/install_copilot_integration.py +0 -564
- package/src/adapters/copilot/mcp_adapter.py +0 -772
- package/src/adapters/copilot/mcp_server.py +0 -168
- package/src/adapters/copilot/standalone_copilot_adapter.py +0 -114
- package/src/adapters/gemini/__init__.py +0 -13
- package/src/adapters/gemini/extension_adapter.py +0 -690
- package/src/adapters/gemini/install_gemini_integration.py +0 -257
- package/src/adapters/gemini/standalone_gemini_adapter.py +0 -366
- package/src/adapters/iflow/__init__.py +0 -7
- package/src/adapters/iflow/hook_adapter.py +0 -1038
- package/src/adapters/iflow/hook_installer.py +0 -536
- package/src/adapters/iflow/install_iflow_integration.py +0 -271
- package/src/adapters/iflow/official_hook_adapter.py +0 -1272
- package/src/adapters/iflow/standalone_iflow_adapter.py +0 -48
- package/src/adapters/iflow/workflow_adapter.py +0 -793
- package/src/adapters/qoder/hook_installer.py +0 -732
- package/src/adapters/qoder/install_qoder_integration.py +0 -265
- package/src/adapters/qoder/notification_hook_adapter.py +0 -863
- package/src/adapters/qoder/standalone_qoder_adapter.py +0 -48
- package/src/adapters/qwen/__init__.py +0 -17
- package/src/adapters/qwencode/__init__.py +0 -13
- package/src/adapters/qwencode/inheritance_adapter.py +0 -818
- package/src/adapters/qwencode/install_qwencode_integration.py +0 -276
- package/src/adapters/qwencode/standalone_qwencode_adapter.py +0 -399
- package/src/atomic_collaboration_handler.py +0 -461
- package/src/cli_collaboration_agent.py +0 -697
- package/src/collaboration/hooks.py +0 -315
- package/src/core/__init__.py +0 -21
- package/src/core/ai_environment_scanner.py +0 -331
- package/src/core/base_adapter.py +0 -220
- package/src/core/cli_hook_integration.py +0 -406
- package/src/core/cross_cli_executor.py +0 -713
- package/src/core/cross_cli_mapping.py +0 -1165
- package/src/core/cross_platform_encoding.py +0 -365
- package/src/core/cross_platform_safe_cli.py +0 -894
- package/src/core/direct_cli_executor.py +0 -805
- package/src/core/direct_cli_hook_system.py +0 -958
- package/src/core/enhanced_init_processor.py +0 -467
- package/src/core/graceful_cli_executor.py +0 -912
- package/src/core/md_enhancer.py +0 -342
- package/src/core/md_generator.py +0 -619
- package/src/core/models.py +0 -218
- package/src/core/parser.py +0 -108
- package/src/core/real_cli_hook_system.py +0 -852
- package/src/core/real_cross_cli_system.py +0 -925
- package/src/core/verified_cross_cli_system.py +0 -961
- package/src/deploy.js +0 -737
- package/src/enhanced-main.js +0 -626
- package/src/enhanced_deploy.js +0 -303
- package/src/enhanced_universal_cli_setup.py +0 -930
- package/src/kimi_wrapper.py +0 -104
- package/src/main.js +0 -1309
- package/src/shell_integration.py +0 -398
- package/src/simple-main.js +0 -315
- package/src/smart_router_creator.py +0 -323
- package/src/universal_cli_setup.py +0 -1289
- package/src/utils/__init__.py +0 -12
- package/src/utils/cli_detector.py +0 -445
- package/src/utils/file_utils.py +0 -246
|
@@ -1,1165 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
跨CLI协作映射表
|
|
5
|
-
定义不同CLI之间的协作关系、参数映射和调用模式
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import json
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
from typing import Dict, List, Any, Tuple, Optional
|
|
11
|
-
from dataclasses import dataclass
|
|
12
|
-
from enum import Enum
|
|
13
|
-
|
|
14
|
-
class CollaborationType(Enum):
|
|
15
|
-
"""协作类型枚举"""
|
|
16
|
-
CODE_REVIEW = "code_review"
|
|
17
|
-
CODE_GENERATION = "code_generation"
|
|
18
|
-
TRANSLATION = "translation"
|
|
19
|
-
OPTIMIZATION = "optimization"
|
|
20
|
-
DEBUGGING = "debugging"
|
|
21
|
-
DOCUMENTATION = "documentation"
|
|
22
|
-
REFACTORING = "refactoring"
|
|
23
|
-
TESTING = "testing"
|
|
24
|
-
ANALYSIS = "analysis"
|
|
25
|
-
WORKFLOW = "workflow"
|
|
26
|
-
TASK_DELEGATION = "task_delegation"
|
|
27
|
-
ANALYSIS_FEEDBACK = "analysis_feedback"
|
|
28
|
-
ORCHESTRATION = "orchestration"
|
|
29
|
-
AUTOMATION = "automation"
|
|
30
|
-
INTEGRATION = "integration"
|
|
31
|
-
EDUCATION = "education"
|
|
32
|
-
TUTORIAL = "tutorial"
|
|
33
|
-
EXPLANATION = "explanation"
|
|
34
|
-
PAIR_PROGRAMMING = "pair_programming"
|
|
35
|
-
CODE_COMPLETION = "code_completion"
|
|
36
|
-
SUGGESTION = "suggestion"
|
|
37
|
-
PATTERN_DETECTION = "pattern_detection"
|
|
38
|
-
MULTI_AGENT = "multi_agent"
|
|
39
|
-
TASK_MANAGEMENT = "task_management"
|
|
40
|
-
TOOL_EXECUTION = "tool_execution"
|
|
41
|
-
CONFIGURATION = "configuration"
|
|
42
|
-
DEPLOYMENT = "deployment"
|
|
43
|
-
|
|
44
|
-
class ParameterMappingType(Enum):
|
|
45
|
-
"""参数映射类型"""
|
|
46
|
-
DIRECT = "direct" # 直接映射
|
|
47
|
-
TRANSFORM = "transform" # 转换映射
|
|
48
|
-
IGNORE = "ignore" # 忽略映射
|
|
49
|
-
CUSTOM = "custom" # 自定义映射
|
|
50
|
-
|
|
51
|
-
@dataclass
|
|
52
|
-
class ParameterMapping:
|
|
53
|
-
"""参数映射定义"""
|
|
54
|
-
source_param: str # 源参数名
|
|
55
|
-
target_param: str # 目标参数名
|
|
56
|
-
mapping_type: ParameterMappingType
|
|
57
|
-
transform_function: str # 转换函数名
|
|
58
|
-
default_value: Any # 默认值
|
|
59
|
-
required: bool # 是否必需
|
|
60
|
-
description: str # 描述
|
|
61
|
-
|
|
62
|
-
@dataclass
|
|
63
|
-
class CollaborationPattern:
|
|
64
|
-
"""协作模式定义"""
|
|
65
|
-
pattern_id: str
|
|
66
|
-
source_cli: str
|
|
67
|
-
target_cli: str
|
|
68
|
-
collaboration_type: CollaborationType
|
|
69
|
-
trigger_phrases: List[str] # 触发短语
|
|
70
|
-
command_template: str # 命令模板
|
|
71
|
-
parameter_mappings: List[ParameterMapping]
|
|
72
|
-
output_format: str # 输出格式
|
|
73
|
-
use_cases: List[str] # 用例
|
|
74
|
-
best_practices: List[str] # 最佳实践
|
|
75
|
-
|
|
76
|
-
@dataclass
|
|
77
|
-
class CLICompatibility:
|
|
78
|
-
"""CLI兼容性信息"""
|
|
79
|
-
cli_name: str
|
|
80
|
-
supported_as_source: List[CollaborationType]
|
|
81
|
-
supported_as_target: List[CollaborationType]
|
|
82
|
-
strengths: List[str] # 强项
|
|
83
|
-
limitations: List[str] # 限制
|
|
84
|
-
preferred_contexts: List[str] # 偏好上下文
|
|
85
|
-
|
|
86
|
-
class CrossCLIMapper:
|
|
87
|
-
"""跨CLI映射器"""
|
|
88
|
-
|
|
89
|
-
def __init__(self):
|
|
90
|
-
self.cli_compatibility = self._initialize_cli_compatibility()
|
|
91
|
-
self.collaboration_patterns = self._initialize_collaboration_patterns()
|
|
92
|
-
self.parameter_transformers = self._initialize_parameter_transformers()
|
|
93
|
-
|
|
94
|
-
def _initialize_cli_compatibility(self) -> Dict[str, CLICompatibility]:
|
|
95
|
-
"""初始化CLI兼容性信息"""
|
|
96
|
-
compatibility = {}
|
|
97
|
-
|
|
98
|
-
# Claude CLI
|
|
99
|
-
compatibility['claude'] = CLICompatibility(
|
|
100
|
-
cli_name='claude',
|
|
101
|
-
supported_as_source=[
|
|
102
|
-
CollaborationType.CODE_REVIEW,
|
|
103
|
-
CollaborationType.ANALYSIS,
|
|
104
|
-
CollaborationType.DOCUMENTATION,
|
|
105
|
-
CollaborationType.DEBUGGING
|
|
106
|
-
],
|
|
107
|
-
supported_as_target=[
|
|
108
|
-
CollaborationType.CODE_GENERATION,
|
|
109
|
-
CollaborationType.TRANSLATION,
|
|
110
|
-
CollaborationType.REFACTORING
|
|
111
|
-
],
|
|
112
|
-
strengths=[
|
|
113
|
-
"代码审查和分析能力强",
|
|
114
|
-
"理解复杂逻辑和架构",
|
|
115
|
-
"详细的解释和建议",
|
|
116
|
-
"自然语言理解优秀"
|
|
117
|
-
],
|
|
118
|
-
limitations=[
|
|
119
|
-
"代码生成速度相对较慢",
|
|
120
|
-
"对特定框架支持有限",
|
|
121
|
-
"API调用有速率限制"
|
|
122
|
-
],
|
|
123
|
-
preferred_contexts=[
|
|
124
|
-
"代码质量审查",
|
|
125
|
-
"架构设计讨论",
|
|
126
|
-
"复杂逻辑分析",
|
|
127
|
-
"技术文档编写"
|
|
128
|
-
]
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
# Gemini CLI
|
|
132
|
-
compatibility['gemini'] = CLICompatibility(
|
|
133
|
-
cli_name='gemini',
|
|
134
|
-
supported_as_source=[
|
|
135
|
-
CollaborationType.TRANSLATION,
|
|
136
|
-
CollaborationType.OPTIMIZATION,
|
|
137
|
-
CollaborationType.ANALYSIS,
|
|
138
|
-
CollaborationType.DOCUMENTATION
|
|
139
|
-
],
|
|
140
|
-
supported_as_target=[
|
|
141
|
-
CollaborationType.CODE_REVIEW,
|
|
142
|
-
CollaborationType.DEBUGGING,
|
|
143
|
-
CollaborationType.WORKFLOW
|
|
144
|
-
],
|
|
145
|
-
strengths=[
|
|
146
|
-
"多语言翻译能力强",
|
|
147
|
-
"图像理解和处理",
|
|
148
|
-
"快速响应和优化",
|
|
149
|
-
"多模态处理能力"
|
|
150
|
-
],
|
|
151
|
-
limitations=[
|
|
152
|
-
"代码深度分析相对较弱",
|
|
153
|
-
"专业领域知识有限",
|
|
154
|
-
"复杂推理能力中等"
|
|
155
|
-
],
|
|
156
|
-
preferred_contexts=[
|
|
157
|
-
"代码翻译和本地化",
|
|
158
|
-
"图像相关代码分析",
|
|
159
|
-
"性能优化建议",
|
|
160
|
-
"快速原型开发"
|
|
161
|
-
]
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
# QwenCode CLI
|
|
165
|
-
compatibility['qwencode'] = CLICompatibility(
|
|
166
|
-
cli_name='qwencode',
|
|
167
|
-
supported_as_source=[
|
|
168
|
-
CollaborationType.CODE_GENERATION,
|
|
169
|
-
CollaborationType.TESTING,
|
|
170
|
-
CollaborationType.DEBUGGING
|
|
171
|
-
],
|
|
172
|
-
supported_as_target=[
|
|
173
|
-
CollaborationType.CODE_REVIEW,
|
|
174
|
-
CollaborationType.REFACTORING,
|
|
175
|
-
CollaborationType.ANALYSIS
|
|
176
|
-
],
|
|
177
|
-
strengths=[
|
|
178
|
-
"中文编程支持优秀",
|
|
179
|
-
"特定领域模型优化",
|
|
180
|
-
"本地化代码生成",
|
|
181
|
-
"中文技术文档处理"
|
|
182
|
-
],
|
|
183
|
-
limitations=[
|
|
184
|
-
"英文支持相对较弱",
|
|
185
|
-
"非中文场景应用有限",
|
|
186
|
-
"协作功能较新"
|
|
187
|
-
],
|
|
188
|
-
preferred_contexts=[
|
|
189
|
-
"中文代码生成",
|
|
190
|
-
"本地化项目开发",
|
|
191
|
-
"中文技术文档",
|
|
192
|
-
"特定行业应用"
|
|
193
|
-
]
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
# iFlow CLI
|
|
197
|
-
compatibility['iflow'] = CLICompatibility(
|
|
198
|
-
cli_name='iflow',
|
|
199
|
-
supported_as_source=[
|
|
200
|
-
CollaborationType.WORKFLOW,
|
|
201
|
-
CollaborationType.AUTOMATION,
|
|
202
|
-
CollaborationType.INTEGRATION
|
|
203
|
-
],
|
|
204
|
-
supported_as_target=[
|
|
205
|
-
CollaborationType.CODE_GENERATION,
|
|
206
|
-
CollaborationType.CONFIGURATION,
|
|
207
|
-
CollaborationType.DEPLOYMENT
|
|
208
|
-
],
|
|
209
|
-
strengths=[
|
|
210
|
-
"工作流设计强大",
|
|
211
|
-
"自动化流程管理",
|
|
212
|
-
"集成能力优秀",
|
|
213
|
-
"可视化流程控制"
|
|
214
|
-
],
|
|
215
|
-
limitations=[
|
|
216
|
-
"非工作流场景有限",
|
|
217
|
-
"学习曲线较陡",
|
|
218
|
-
"配置较复杂"
|
|
219
|
-
],
|
|
220
|
-
preferred_contexts=[
|
|
221
|
-
"CI/CD流程设计",
|
|
222
|
-
"自动化工作流",
|
|
223
|
-
"集成测试流程",
|
|
224
|
-
"部署管道管理"
|
|
225
|
-
]
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
# Qoder CLI
|
|
229
|
-
compatibility['qoder'] = CLICompatibility(
|
|
230
|
-
cli_name='qoder',
|
|
231
|
-
supported_as_source=[
|
|
232
|
-
CollaborationType.CODE_GENERATION,
|
|
233
|
-
CollaborationType.TEMPLATE_CREATION,
|
|
234
|
-
CollaborationType.SNIPPET_GENERATION
|
|
235
|
-
],
|
|
236
|
-
supported_as_target=[
|
|
237
|
-
CollaborationType.CODE_REVIEW,
|
|
238
|
-
CollaborationType.REFACTORING,
|
|
239
|
-
CollaborationType.OPTIMIZATION
|
|
240
|
-
],
|
|
241
|
-
strengths=[
|
|
242
|
-
"代码片段生成优秀",
|
|
243
|
-
"模板库丰富",
|
|
244
|
-
"快速原型开发",
|
|
245
|
-
"多语言支持"
|
|
246
|
-
],
|
|
247
|
-
limitations=[
|
|
248
|
-
"深度分析能力有限",
|
|
249
|
-
"复杂逻辑处理较弱",
|
|
250
|
-
"协作功能较基础"
|
|
251
|
-
],
|
|
252
|
-
preferred_contexts=[
|
|
253
|
-
"代码片段生成",
|
|
254
|
-
"模板创建",
|
|
255
|
-
"快速原型开发",
|
|
256
|
-
"代码补全"
|
|
257
|
-
]
|
|
258
|
-
)
|
|
259
|
-
|
|
260
|
-
# CodeBuddy CLI
|
|
261
|
-
compatibility['codebuddy'] = CLICompatibility(
|
|
262
|
-
cli_name='codebuddy',
|
|
263
|
-
supported_as_source=[
|
|
264
|
-
CollaborationType.EDUCATION,
|
|
265
|
-
CollaborationType.TUTORIAL,
|
|
266
|
-
CollaborationType.EXPLANATION
|
|
267
|
-
],
|
|
268
|
-
supported_as_target=[
|
|
269
|
-
CollaborationType.CODE_GENERATION,
|
|
270
|
-
CollaborationType.DEBUGGING,
|
|
271
|
-
CollaborationType.TESTING
|
|
272
|
-
],
|
|
273
|
-
strengths=[
|
|
274
|
-
"教学和解释能力强",
|
|
275
|
-
"循序渐进的指导",
|
|
276
|
-
"适合初学者",
|
|
277
|
-
"知识传授优秀"
|
|
278
|
-
],
|
|
279
|
-
limitations=[
|
|
280
|
-
"高级开发能力有限",
|
|
281
|
-
"复杂项目处理较弱",
|
|
282
|
-
"性能不是最优"
|
|
283
|
-
],
|
|
284
|
-
preferred_contexts=[
|
|
285
|
-
"编程学习",
|
|
286
|
-
"技术教学",
|
|
287
|
-
"代码解释",
|
|
288
|
-
"最佳实践指导"
|
|
289
|
-
]
|
|
290
|
-
)
|
|
291
|
-
|
|
292
|
-
# Copilot CLI
|
|
293
|
-
compatibility['copilot'] = CLICompatibility(
|
|
294
|
-
cli_name='copilot',
|
|
295
|
-
supported_as_source=[
|
|
296
|
-
CollaborationType.PAIR_PROGRAMMING,
|
|
297
|
-
CollaborationType.CODE_COMPLETION,
|
|
298
|
-
CollaborationType.SUGGESTION
|
|
299
|
-
],
|
|
300
|
-
supported_as_target=[
|
|
301
|
-
CollaborationType.CODE_REVIEW,
|
|
302
|
-
CollaborationType.REFACTORING,
|
|
303
|
-
CollaborationType.OPTIMIZATION
|
|
304
|
-
],
|
|
305
|
-
strengths=[
|
|
306
|
-
"实时代码补全",
|
|
307
|
-
"上下文理解强",
|
|
308
|
-
"IDE集成优秀",
|
|
309
|
-
"快速响应"
|
|
310
|
-
],
|
|
311
|
-
limitations=[
|
|
312
|
-
"独立使用能力有限",
|
|
313
|
-
"深度分析相对较弱",
|
|
314
|
-
"依赖编辑器环境"
|
|
315
|
-
],
|
|
316
|
-
preferred_contexts=[
|
|
317
|
-
"代码编写",
|
|
318
|
-
"实时补全",
|
|
319
|
-
"小范围重构",
|
|
320
|
-
"代码建议"
|
|
321
|
-
]
|
|
322
|
-
)
|
|
323
|
-
|
|
324
|
-
# Codex CLI
|
|
325
|
-
compatibility['codex'] = CLICompatibility(
|
|
326
|
-
cli_name='codex',
|
|
327
|
-
supported_as_source=[
|
|
328
|
-
CollaborationType.CODE_ANALYSIS,
|
|
329
|
-
CollaborationType.PATTERN_DETECTION,
|
|
330
|
-
CollaborationType.OPTIMIZATION
|
|
331
|
-
],
|
|
332
|
-
supported_as_target=[
|
|
333
|
-
CollaborationType.CODE_GENERATION,
|
|
334
|
-
CollaborationType.REFACTORING,
|
|
335
|
-
CollaborationType.DOCUMENTATION
|
|
336
|
-
],
|
|
337
|
-
strengths=[
|
|
338
|
-
"代码模式识别强",
|
|
339
|
-
"深层代码分析",
|
|
340
|
-
"架构优化建议",
|
|
341
|
-
"代码质量评估"
|
|
342
|
-
],
|
|
343
|
-
limitations=[
|
|
344
|
-
"生成代码较基础",
|
|
345
|
-
"交互体验一般",
|
|
346
|
-
"API费用较高"
|
|
347
|
-
],
|
|
348
|
-
preferred_contexts=[
|
|
349
|
-
"代码质量分析",
|
|
350
|
-
"架构优化",
|
|
351
|
-
"模式识别",
|
|
352
|
-
"代码审查"
|
|
353
|
-
]
|
|
354
|
-
)
|
|
355
|
-
|
|
356
|
-
# Cline CLI
|
|
357
|
-
compatibility['cline'] = CLICompatibility(
|
|
358
|
-
cli_name='cline',
|
|
359
|
-
supported_as_source=[
|
|
360
|
-
CollaborationType.TASK_MANAGEMENT,
|
|
361
|
-
CollaborationType.MULTI_AGENT,
|
|
362
|
-
CollaborationType.WORKFLOW,
|
|
363
|
-
CollaborationType.TOOL_EXECUTION
|
|
364
|
-
],
|
|
365
|
-
supported_as_target=[
|
|
366
|
-
CollaborationType.CODE_GENERATION,
|
|
367
|
-
CollaborationType.DEBUGGING,
|
|
368
|
-
CollaborationType.REFACTORING,
|
|
369
|
-
CollaborationType.DOCUMENTATION,
|
|
370
|
-
CollaborationType.TESTING
|
|
371
|
-
],
|
|
372
|
-
strengths=[
|
|
373
|
-
"任务生命周期管理",
|
|
374
|
-
"多智能体编排能力",
|
|
375
|
-
"Hook系统集成",
|
|
376
|
-
"终端命令执行",
|
|
377
|
-
"MCP工具支持",
|
|
378
|
-
"跨CLI委托功能"
|
|
379
|
-
],
|
|
380
|
-
limitations=[
|
|
381
|
-
"Windows平台支持有限",
|
|
382
|
-
"配置相对复杂",
|
|
383
|
-
"学习曲线较陡",
|
|
384
|
-
"依赖外部API服务"
|
|
385
|
-
],
|
|
386
|
-
preferred_contexts=[
|
|
387
|
-
"复杂任务管理",
|
|
388
|
-
"多步骤工作流",
|
|
389
|
-
"终端操作自动化",
|
|
390
|
-
"跨CLI协作",
|
|
391
|
-
"项目级开发任务"
|
|
392
|
-
]
|
|
393
|
-
)
|
|
394
|
-
|
|
395
|
-
return compatibility
|
|
396
|
-
|
|
397
|
-
def _initialize_collaboration_patterns(self) -> Dict[str, CollaborationPattern]:
|
|
398
|
-
"""初始化协作模式"""
|
|
399
|
-
patterns = {}
|
|
400
|
-
|
|
401
|
-
# Claude -> Gemini 协作模式
|
|
402
|
-
patterns['claude_to_gemini'] = CollaborationPattern(
|
|
403
|
-
pattern_id='claude_to_gemini',
|
|
404
|
-
source_cli='claude',
|
|
405
|
-
target_cli='gemini',
|
|
406
|
-
collaboration_type=CollaborationType.TRANSLATION,
|
|
407
|
-
trigger_phrases=[
|
|
408
|
-
'请用gemini帮我翻译',
|
|
409
|
-
'use gemini to translate',
|
|
410
|
-
'让gemini处理多语言',
|
|
411
|
-
'gemini翻译这段'
|
|
412
|
-
],
|
|
413
|
-
command_template='gemini --file {input_file} --prompt "{context}: {request}"',
|
|
414
|
-
parameter_mappings=[
|
|
415
|
-
ParameterMapping(
|
|
416
|
-
source_param='request',
|
|
417
|
-
target_param='prompt',
|
|
418
|
-
mapping_type=ParameterMappingType.DIRECT,
|
|
419
|
-
transform_function='',
|
|
420
|
-
default_value='',
|
|
421
|
-
required=True,
|
|
422
|
-
description='翻译请求内容'
|
|
423
|
-
),
|
|
424
|
-
ParameterMapping(
|
|
425
|
-
source_param='input_file',
|
|
426
|
-
target_param='file',
|
|
427
|
-
mapping_type=ParameterMappingType.DIRECT,
|
|
428
|
-
transform_function='',
|
|
429
|
-
default_value=None,
|
|
430
|
-
required=False,
|
|
431
|
-
description='输入文件路径'
|
|
432
|
-
)
|
|
433
|
-
],
|
|
434
|
-
output_format='text',
|
|
435
|
-
use_cases=[
|
|
436
|
-
'代码国际化',
|
|
437
|
-
'技术文档翻译',
|
|
438
|
-
'多语言注释转换',
|
|
439
|
-
'跨语言项目适配'
|
|
440
|
-
],
|
|
441
|
-
best_practices=[
|
|
442
|
-
'提供上下文信息以获得更好翻译',
|
|
443
|
-
'明确目标语言和术语规范',
|
|
444
|
-
'保持代码格式和结构',
|
|
445
|
-
'验证翻译后的功能正确性'
|
|
446
|
-
]
|
|
447
|
-
)
|
|
448
|
-
|
|
449
|
-
# Gemini -> Claude 协作模式
|
|
450
|
-
patterns['gemini_to_claude'] = CollaborationPattern(
|
|
451
|
-
pattern_id='gemini_to_claude',
|
|
452
|
-
source_cli='gemini',
|
|
453
|
-
target_cli='claude',
|
|
454
|
-
collaboration_type=CollaborationType.CODE_REVIEW,
|
|
455
|
-
trigger_phrases=[
|
|
456
|
-
'请用claude帮我审查',
|
|
457
|
-
'use claude to review',
|
|
458
|
-
'让claude分析这段代码',
|
|
459
|
-
'claude审查代码质量'
|
|
460
|
-
],
|
|
461
|
-
command_template='claude --file {input_file} --prompt "{context}: 深度审查: {request}"',
|
|
462
|
-
parameter_mappings=[
|
|
463
|
-
ParameterMapping(
|
|
464
|
-
source_param='request',
|
|
465
|
-
target_param='prompt',
|
|
466
|
-
mapping_type=ParameterMappingType.TRANSFORM,
|
|
467
|
-
transform_function='add_review_context',
|
|
468
|
-
default_value='',
|
|
469
|
-
required=True,
|
|
470
|
-
description='审查请求'
|
|
471
|
-
),
|
|
472
|
-
ParameterMapping(
|
|
473
|
-
source_param='input_file',
|
|
474
|
-
target_param='file',
|
|
475
|
-
mapping_type=ParameterMappingType.DIRECT,
|
|
476
|
-
transform_function='',
|
|
477
|
-
default_value=None,
|
|
478
|
-
required=True,
|
|
479
|
-
description='待审查文件'
|
|
480
|
-
)
|
|
481
|
-
],
|
|
482
|
-
output_format='detailed_analysis',
|
|
483
|
-
use_cases=[
|
|
484
|
-
'代码质量审查',
|
|
485
|
-
'安全性检查',
|
|
486
|
-
'性能分析',
|
|
487
|
-
'架构评估'
|
|
488
|
-
],
|
|
489
|
-
best_practices=[
|
|
490
|
-
'提供完整的代码上下文',
|
|
491
|
-
'明确审查的重点和标准',
|
|
492
|
-
'关注安全性和性能问题',
|
|
493
|
-
'考虑维护性和可扩展性'
|
|
494
|
-
]
|
|
495
|
-
)
|
|
496
|
-
|
|
497
|
-
# QwenCode -> Claude 协作模式
|
|
498
|
-
patterns['qwencode_to_claude'] = CollaborationPattern(
|
|
499
|
-
pattern_id='qwencode_to_claude',
|
|
500
|
-
source_cli='qwencode',
|
|
501
|
-
target_cli='claude',
|
|
502
|
-
collaboration_type=CollaborationType.DOCUMENTATION,
|
|
503
|
-
trigger_phrases=[
|
|
504
|
-
'请用claude帮我写文档',
|
|
505
|
-
'用claude生成技术文档',
|
|
506
|
-
'claude帮我完善注释',
|
|
507
|
-
'claude编写API文档'
|
|
508
|
-
],
|
|
509
|
-
command_template='claude --file {input_file} --prompt "基于以下代码生成详细的技术文档: {request}"',
|
|
510
|
-
parameter_mappings=[
|
|
511
|
-
ParameterMapping(
|
|
512
|
-
source_param='request',
|
|
513
|
-
target_param='prompt',
|
|
514
|
-
mapping_type=ParameterMappingType.TRANSFORM,
|
|
515
|
-
transform_function='add_documentation_context',
|
|
516
|
-
default_value='',
|
|
517
|
-
required=True,
|
|
518
|
-
description='文档生成请求'
|
|
519
|
-
)
|
|
520
|
-
],
|
|
521
|
-
output_format='markdown',
|
|
522
|
-
use_cases=[
|
|
523
|
-
'API文档生成',
|
|
524
|
-
'代码注释完善',
|
|
525
|
-
'技术手册编写',
|
|
526
|
-
'用户指南创建'
|
|
527
|
-
],
|
|
528
|
-
best_practices=[
|
|
529
|
-
'遵循文档标准格式',
|
|
530
|
-
'包含使用示例',
|
|
531
|
-
'提供参数和返回值说明',
|
|
532
|
-
'添加错误处理说明'
|
|
533
|
-
]
|
|
534
|
-
)
|
|
535
|
-
|
|
536
|
-
# iFlow -> Qoder 协作模式
|
|
537
|
-
patterns['iflow_to_qoder'] = CollaborationPattern(
|
|
538
|
-
pattern_id='iflow_to_qoder',
|
|
539
|
-
source_cli='iflow',
|
|
540
|
-
target_cli='qoder',
|
|
541
|
-
collaboration_type=CollaborationType.CODE_GENERATION,
|
|
542
|
-
trigger_phrases=[
|
|
543
|
-
'请用qoder生成代码',
|
|
544
|
-
'用qoder创建实现',
|
|
545
|
-
'qoder帮我写组件',
|
|
546
|
-
'qoder生成模板代码'
|
|
547
|
-
],
|
|
548
|
-
command_template='qoder --template {template_name} --output {output_file} --context "{context}"',
|
|
549
|
-
parameter_mappings=[
|
|
550
|
-
ParameterMapping(
|
|
551
|
-
source_param='workflow_config',
|
|
552
|
-
target_param='template_name',
|
|
553
|
-
mapping_type=ParameterMappingType.TRANSFORM,
|
|
554
|
-
transform_function='extract_template_from_workflow',
|
|
555
|
-
default_value='default',
|
|
556
|
-
required=True,
|
|
557
|
-
description='工作流模板名'
|
|
558
|
-
)
|
|
559
|
-
],
|
|
560
|
-
output_format='code',
|
|
561
|
-
use_cases=[
|
|
562
|
-
'工作流实现代码',
|
|
563
|
-
'自动化脚本生成',
|
|
564
|
-
'配置文件生成',
|
|
565
|
-
'集成代码模板'
|
|
566
|
-
],
|
|
567
|
-
best_practices=[
|
|
568
|
-
'遵循工作流规范',
|
|
569
|
-
'确保代码可维护性',
|
|
570
|
-
'添加错误处理',
|
|
571
|
-
'包含配置验证'
|
|
572
|
-
]
|
|
573
|
-
)
|
|
574
|
-
|
|
575
|
-
# Copilot -> Codex 协作模式
|
|
576
|
-
patterns['copilot_to_codex'] = CollaborationPattern(
|
|
577
|
-
pattern_id='copilot_to_codex',
|
|
578
|
-
source_cli='copilot',
|
|
579
|
-
target_cli='codex',
|
|
580
|
-
collaboration_type=CollaborationType.PATTERN_DETECTION,
|
|
581
|
-
trigger_phrases=[
|
|
582
|
-
'请用codex分析模式',
|
|
583
|
-
'codex检测代码模式',
|
|
584
|
-
'codex识别架构模式',
|
|
585
|
-
'codex分析设计模式'
|
|
586
|
-
],
|
|
587
|
-
command_template='codex --file {input_file} --analysis-type pattern --context "{context}"',
|
|
588
|
-
parameter_mappings=[
|
|
589
|
-
ParameterMapping(
|
|
590
|
-
source_param='context',
|
|
591
|
-
target_param='context',
|
|
592
|
-
mapping_type=ParameterMappingType.TRANSFORM,
|
|
593
|
-
transform_function='add_pattern_analysis_context',
|
|
594
|
-
default_value='',
|
|
595
|
-
required=False,
|
|
596
|
-
description='分析上下文'
|
|
597
|
-
)
|
|
598
|
-
],
|
|
599
|
-
output_format='analysis_report',
|
|
600
|
-
use_cases=[
|
|
601
|
-
'设计模式识别',
|
|
602
|
-
'代码结构分析',
|
|
603
|
-
'架构模式检测',
|
|
604
|
-
'重构建议生成'
|
|
605
|
-
],
|
|
606
|
-
best_practices=[
|
|
607
|
-
'提供完整的代码库视图',
|
|
608
|
-
'关注设计原则遵循',
|
|
609
|
-
'识别反模式和问题',
|
|
610
|
-
'提供改进建议'
|
|
611
|
-
]
|
|
612
|
-
)
|
|
613
|
-
|
|
614
|
-
# CodeBuddy -> Gemini 协作模式
|
|
615
|
-
patterns['codebuddy_to_gemini'] = CollaborationPattern(
|
|
616
|
-
pattern_id='codebuddy_to_gemini',
|
|
617
|
-
source_cli='codebuddy',
|
|
618
|
-
target_cli='gemini',
|
|
619
|
-
collaboration_type=CollaborationType.OPTIMIZATION,
|
|
620
|
-
trigger_phrases=[
|
|
621
|
-
'请用gemini优化代码',
|
|
622
|
-
'gemini帮我提升性能',
|
|
623
|
-
'gemini优化这段算法',
|
|
624
|
-
'gemini改进代码效率'
|
|
625
|
-
],
|
|
626
|
-
command_template='gemini --file {input_file} --optimize --suggestions "{optimization_goals}"',
|
|
627
|
-
parameter_mappings=[
|
|
628
|
-
ParameterMapping(
|
|
629
|
-
source_param='learning_objectives',
|
|
630
|
-
target_param='optimization_goals',
|
|
631
|
-
mapping_type=ParameterMappingType.TRANSFORM,
|
|
632
|
-
transform_function='convert_learning_to_goals',
|
|
633
|
-
default_value='performance',
|
|
634
|
-
required=False,
|
|
635
|
-
description='优化目标'
|
|
636
|
-
)
|
|
637
|
-
],
|
|
638
|
-
output_format='suggestions',
|
|
639
|
-
use_cases=[
|
|
640
|
-
'性能优化',
|
|
641
|
-
'内存使用优化',
|
|
642
|
-
'算法改进',
|
|
643
|
-
'代码效率提升'
|
|
644
|
-
],
|
|
645
|
-
best_practices=[
|
|
646
|
-
'明确优化目标',
|
|
647
|
-
'保持代码可读性',
|
|
648
|
-
'测试优化效果',
|
|
649
|
-
'考虑安全性影响'
|
|
650
|
-
]
|
|
651
|
-
)
|
|
652
|
-
|
|
653
|
-
# 添加更多协作模式...
|
|
654
|
-
|
|
655
|
-
# Cline协作模式
|
|
656
|
-
|
|
657
|
-
# Claude -> Cline 协作模式 (任务委托)
|
|
658
|
-
patterns['claude_to_cline'] = CollaborationPattern(
|
|
659
|
-
pattern_id='claude_to_cline',
|
|
660
|
-
source_cli='claude',
|
|
661
|
-
target_cli='cline',
|
|
662
|
-
collaboration_type=CollaborationType.TASK_DELEGATION,
|
|
663
|
-
trigger_phrases=[
|
|
664
|
-
'请用cline执行任务',
|
|
665
|
-
'cline帮我执行',
|
|
666
|
-
'让cline处理复杂任务',
|
|
667
|
-
'cline执行终端操作',
|
|
668
|
-
'use cline to execute',
|
|
669
|
-
'delegate to cline'
|
|
670
|
-
],
|
|
671
|
-
command_template='cline execute --task "{task_description}" --context "{execution_context}"',
|
|
672
|
-
parameter_mappings=[
|
|
673
|
-
ParameterMapping(
|
|
674
|
-
source_param='request',
|
|
675
|
-
target_param='task_description',
|
|
676
|
-
mapping_type=ParameterMappingType.TRANSFORM,
|
|
677
|
-
transform_function='extract_execution_task',
|
|
678
|
-
default_value='',
|
|
679
|
-
required=True,
|
|
680
|
-
description='执行任务的详细描述'
|
|
681
|
-
),
|
|
682
|
-
ParameterMapping(
|
|
683
|
-
source_param='context',
|
|
684
|
-
target_param='execution_context',
|
|
685
|
-
mapping_type=ParameterMappingType.DIRECT,
|
|
686
|
-
transform_function='',
|
|
687
|
-
default_value='cross-cli delegation from Claude',
|
|
688
|
-
required=False,
|
|
689
|
-
description='执行上下文信息'
|
|
690
|
-
)
|
|
691
|
-
],
|
|
692
|
-
output_format='execution_result',
|
|
693
|
-
use_cases=[
|
|
694
|
-
'复杂多步骤任务执行',
|
|
695
|
-
'终端命令自动化',
|
|
696
|
-
'项目级开发任务',
|
|
697
|
-
'跨工具工作流协调'
|
|
698
|
-
],
|
|
699
|
-
best_practices=[
|
|
700
|
-
'提供清晰的任务描述',
|
|
701
|
-
'指定必要的执行上下文',
|
|
702
|
-
'监控执行进度和结果',
|
|
703
|
-
'处理可能的错误和异常'
|
|
704
|
-
]
|
|
705
|
-
)
|
|
706
|
-
|
|
707
|
-
# Cline -> Claude 协作模式 (分析反馈)
|
|
708
|
-
patterns['cline_to_claude'] = CollaborationPattern(
|
|
709
|
-
pattern_id='cline_to_claude',
|
|
710
|
-
source_cli='cline',
|
|
711
|
-
target_cli='claude',
|
|
712
|
-
collaboration_type=CollaborationType.ANALYSIS_FEEDBACK,
|
|
713
|
-
trigger_phrases=[
|
|
714
|
-
'请claude分析执行结果',
|
|
715
|
-
'claude帮我总结',
|
|
716
|
-
'让claude解释执行输出',
|
|
717
|
-
'claude分析任务结果',
|
|
718
|
-
'use claude to analyze',
|
|
719
|
-
'claude review execution'
|
|
720
|
-
],
|
|
721
|
-
command_template='claude --analyze "{execution_output}" --context "{task_context}"',
|
|
722
|
-
parameter_mappings=[
|
|
723
|
-
ParameterMapping(
|
|
724
|
-
source_param='execution_result',
|
|
725
|
-
target_param='execution_output',
|
|
726
|
-
mapping_type=ParameterMappingType.DIRECT,
|
|
727
|
-
transform_function='',
|
|
728
|
-
default_value='',
|
|
729
|
-
required=True,
|
|
730
|
-
description='Cline执行结果'
|
|
731
|
-
),
|
|
732
|
-
ParameterMapping(
|
|
733
|
-
source_param='task_description',
|
|
734
|
-
target_param='task_context',
|
|
735
|
-
mapping_type=ParameterMappingType.DIRECT,
|
|
736
|
-
transform_function='',
|
|
737
|
-
default_value='',
|
|
738
|
-
required=False,
|
|
739
|
-
description='原始任务上下文'
|
|
740
|
-
)
|
|
741
|
-
],
|
|
742
|
-
output_format='analysis_report',
|
|
743
|
-
use_cases=[
|
|
744
|
-
'执行结果分析',
|
|
745
|
-
'任务总结报告',
|
|
746
|
-
'错误原因分析',
|
|
747
|
-
'性能评估反馈'
|
|
748
|
-
],
|
|
749
|
-
best_practices=[
|
|
750
|
-
'提供完整的执行输出',
|
|
751
|
-
'包含原始任务信息',
|
|
752
|
-
'关注关键指标和异常',
|
|
753
|
-
'提出改进建议'
|
|
754
|
-
]
|
|
755
|
-
)
|
|
756
|
-
|
|
757
|
-
# Multi-CLI -> Cline 协作模式 (任务编排)
|
|
758
|
-
patterns['multi_to_cline_orchestration'] = CollaborationPattern(
|
|
759
|
-
pattern_id='multi_to_cline_orchestration',
|
|
760
|
-
source_cli='multi',
|
|
761
|
-
target_cli='cline',
|
|
762
|
-
collaboration_type=CollaborationType.ORCHESTRATION,
|
|
763
|
-
trigger_phrases=[
|
|
764
|
-
'协调多个CLI工具',
|
|
765
|
-
'cline编排任务',
|
|
766
|
-
'多工具协作管理',
|
|
767
|
-
'cline协调执行',
|
|
768
|
-
'orchestrate with cline',
|
|
769
|
-
'coordinate multi-cli'
|
|
770
|
-
],
|
|
771
|
-
command_template='cline orchestrate --workflow "{workflow_definition}" --tools "{available_tools}"',
|
|
772
|
-
parameter_mappings=[
|
|
773
|
-
ParameterMapping(
|
|
774
|
-
source_param='workflow_request',
|
|
775
|
-
target_param='workflow_definition',
|
|
776
|
-
mapping_type=ParameterMappingType.TRANSFORM,
|
|
777
|
-
transform_function='create_workflow_definition',
|
|
778
|
-
default_value='',
|
|
779
|
-
required=True,
|
|
780
|
-
description='工作流定义'
|
|
781
|
-
),
|
|
782
|
-
ParameterMapping(
|
|
783
|
-
source_param='available_clis',
|
|
784
|
-
target_param='available_tools',
|
|
785
|
-
mapping_type=ParameterMappingType.DIRECT,
|
|
786
|
-
transform_function='',
|
|
787
|
-
default_value='claude,gemini,qwen',
|
|
788
|
-
required=False,
|
|
789
|
-
description='可用CLI工具列表'
|
|
790
|
-
)
|
|
791
|
-
],
|
|
792
|
-
output_format='orchestration_result',
|
|
793
|
-
use_cases=[
|
|
794
|
-
'多CLI工具协调',
|
|
795
|
-
'复杂工作流管理',
|
|
796
|
-
'任务依赖处理',
|
|
797
|
-
'执行状态监控'
|
|
798
|
-
],
|
|
799
|
-
best_practices=[
|
|
800
|
-
'定义清晰的工作流步骤',
|
|
801
|
-
'设置适当的依赖关系',
|
|
802
|
-
'监控执行状态和进度',
|
|
803
|
-
'处理错误和重试机制'
|
|
804
|
-
]
|
|
805
|
-
)
|
|
806
|
-
|
|
807
|
-
return patterns
|
|
808
|
-
|
|
809
|
-
def _initialize_parameter_transformers(self) -> Dict[str, str]:
|
|
810
|
-
"""初始化参数转换器"""
|
|
811
|
-
return {
|
|
812
|
-
'add_review_context': '''
|
|
813
|
-
def add_review_context(request, source_info):
|
|
814
|
-
"""为代码审查添加上下文"""
|
|
815
|
-
return f"""
|
|
816
|
-
请对以下代码进行深度审查:
|
|
817
|
-
1. 安全性分析:检查潜在安全漏洞
|
|
818
|
-
2. 性能评估:识别性能瓶颈和优化机会
|
|
819
|
-
3. 代码质量:评估可读性、维护性和规范性
|
|
820
|
-
4. 架构设计:评估结构合理性和扩展性
|
|
821
|
-
5. 最佳实践:检查是否遵循编程最佳实践
|
|
822
|
-
|
|
823
|
-
用户请求:{request}
|
|
824
|
-
|
|
825
|
-
请提供详细的审查报告,包括问题发现、风险评估和改进建议。
|
|
826
|
-
"""
|
|
827
|
-
''',
|
|
828
|
-
|
|
829
|
-
'add_documentation_context': '''
|
|
830
|
-
def add_documentation_context(request, source_info):
|
|
831
|
-
"""为文档生成添加上下文"""
|
|
832
|
-
return f"""
|
|
833
|
-
基于以下代码生成专业的技术文档:
|
|
834
|
-
|
|
835
|
-
文档要求:
|
|
836
|
-
1. 结构清晰,层次分明
|
|
837
|
-
2. 包含完整的API文档
|
|
838
|
-
3. 提供使用示例和场景
|
|
839
|
-
4. 添加错误处理说明
|
|
840
|
-
5. 遵循Markdown格式规范
|
|
841
|
-
|
|
842
|
-
用户请求:{request}
|
|
843
|
-
|
|
844
|
-
请生成包含以下部分的技术文档:
|
|
845
|
-
- 功能概述
|
|
846
|
-
- API参考
|
|
847
|
-
- 使用示例
|
|
848
|
-
- 配置说明
|
|
849
|
-
- 故障排除
|
|
850
|
-
"""
|
|
851
|
-
''',
|
|
852
|
-
|
|
853
|
-
'extract_template_from_workflow': '''
|
|
854
|
-
def extract_template_from_workflow(workflow_config):
|
|
855
|
-
"""从工作流配置提取模板信息"""
|
|
856
|
-
if isinstance(workflow_config, dict):
|
|
857
|
-
return workflow_config.get('template', 'default')
|
|
858
|
-
elif isinstance(workflow_config, str):
|
|
859
|
-
return workflow_config.split('/')[-1] if '/' in workflow_config else 'default'
|
|
860
|
-
else:
|
|
861
|
-
return 'default'
|
|
862
|
-
''',
|
|
863
|
-
|
|
864
|
-
'add_pattern_analysis_context': '''
|
|
865
|
-
def add_pattern_analysis_context(context):
|
|
866
|
-
"""为模式分析添加上下文"""
|
|
867
|
-
return f"""
|
|
868
|
-
请对代码进行设计模式和架构模式分析:
|
|
869
|
-
|
|
870
|
-
分析重点:
|
|
871
|
-
1. 识别使用的设计模式
|
|
872
|
-
2. 评估模式实现的正确性
|
|
873
|
-
3. 检查是否遵循SOLID原则
|
|
874
|
-
4. 识别代码异味和反模式
|
|
875
|
-
5. 提供重构建议
|
|
876
|
-
|
|
877
|
-
上下文信息:{context}
|
|
878
|
-
|
|
879
|
-
请提供详细的模式分析报告。
|
|
880
|
-
"""
|
|
881
|
-
''',
|
|
882
|
-
|
|
883
|
-
'convert_learning_to_goals': '''
|
|
884
|
-
def convert_learning_to_goals(learning_objectives):
|
|
885
|
-
"""将学习目标转换为优化目标"""
|
|
886
|
-
if not learning_objectives:
|
|
887
|
-
return "性能优化、可读性改进、错误处理增强"
|
|
888
|
-
|
|
889
|
-
goal_mapping = {
|
|
890
|
-
"理解代码结构": "代码结构优化",
|
|
891
|
-
"学习最佳实践": "应用最佳实践",
|
|
892
|
-
"掌握算法": "算法优化",
|
|
893
|
-
"提高编程技巧": "代码质量提升"
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
goals = []
|
|
897
|
-
for objective in str(learning_objectives).split(','):
|
|
898
|
-
goal = goal_mapping.get(objective.strip(), objective.strip())
|
|
899
|
-
goals.append(goal)
|
|
900
|
-
|
|
901
|
-
return ", ".join(goals)
|
|
902
|
-
'''
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
def find_collaboration_pattern(self, source_cli: str, target_cli: str,
|
|
906
|
-
collaboration_type: CollaborationType) -> Optional[CollaborationPattern]:
|
|
907
|
-
"""查找协作模式"""
|
|
908
|
-
pattern_key = f"{source_cli}_to_{target_cli}"
|
|
909
|
-
return self.collaboration_patterns.get(pattern_key)
|
|
910
|
-
|
|
911
|
-
def get_cli_compatibility(self, cli_name: str) -> Optional[CLICompatibility]:
|
|
912
|
-
"""获取CLI兼容性信息"""
|
|
913
|
-
return self.cli_compatibility.get(cli_name)
|
|
914
|
-
|
|
915
|
-
def suggest_optimal_collaboration(self, task_description: str,
|
|
916
|
-
available_clis: List[str]) -> List[Tuple[str, str, float]]:
|
|
917
|
-
"""建议最优协作方案"""
|
|
918
|
-
suggestions = []
|
|
919
|
-
|
|
920
|
-
# 简单的关键词匹配逻辑
|
|
921
|
-
task_keywords = task_description.lower()
|
|
922
|
-
|
|
923
|
-
for source_cli in available_clis:
|
|
924
|
-
source_compat = self.cli_compatibility.get(source_cli)
|
|
925
|
-
if not source_compat:
|
|
926
|
-
continue
|
|
927
|
-
|
|
928
|
-
for target_cli in available_clis:
|
|
929
|
-
if target_cli == source_cli:
|
|
930
|
-
continue
|
|
931
|
-
|
|
932
|
-
target_compat = self.cli_compatibility.get(target_cli)
|
|
933
|
-
if not target_compat:
|
|
934
|
-
continue
|
|
935
|
-
|
|
936
|
-
# 计算匹配分数
|
|
937
|
-
score = self._calculate_collaboration_score(
|
|
938
|
-
task_keywords, source_compat, target_compat
|
|
939
|
-
)
|
|
940
|
-
|
|
941
|
-
if score > 0.3: # 阈值
|
|
942
|
-
suggestions.append((source_cli, target_cli, score))
|
|
943
|
-
|
|
944
|
-
# 按分数排序
|
|
945
|
-
suggestions.sort(key=lambda x: x[2], reverse=True)
|
|
946
|
-
return suggestions[:5] # 返回前5个建议
|
|
947
|
-
|
|
948
|
-
def _calculate_collaboration_score(self, task_keywords: str,
|
|
949
|
-
source_compat: CLICompatibility,
|
|
950
|
-
target_compat: CLICompatibility) -> float:
|
|
951
|
-
"""计算协作分数"""
|
|
952
|
-
score = 0.0
|
|
953
|
-
|
|
954
|
-
# 基于强项和任务关键词匹配
|
|
955
|
-
for strength in source_compat.strengths:
|
|
956
|
-
if any(keyword in strength.lower() for keyword in task_keywords.split()):
|
|
957
|
-
score += 0.3
|
|
958
|
-
|
|
959
|
-
for strength in target_compat.strengths:
|
|
960
|
-
if any(keyword in strength.lower() for keyword in task_keywords.split()):
|
|
961
|
-
score += 0.3
|
|
962
|
-
|
|
963
|
-
# 基于偏好上下文匹配
|
|
964
|
-
for context in source_compat.preferred_contexts:
|
|
965
|
-
if any(keyword in context.lower() for keyword in task_keywords.split()):
|
|
966
|
-
score += 0.2
|
|
967
|
-
|
|
968
|
-
# 基于兼容性匹配
|
|
969
|
-
if any("审查" in strength for strength in target_compat.strengths):
|
|
970
|
-
if "审查" in task_keywords or "分析" in task_keywords:
|
|
971
|
-
score += 0.2
|
|
972
|
-
|
|
973
|
-
return min(score, 1.0) # 最大分数为1.0
|
|
974
|
-
|
|
975
|
-
def transform_parameters(self, pattern: CollaborationPattern,
|
|
976
|
-
source_params: Dict[str, Any]) -> Dict[str, Any]:
|
|
977
|
-
"""转换参数"""
|
|
978
|
-
target_params = {}
|
|
979
|
-
|
|
980
|
-
for mapping in pattern.parameter_mappings:
|
|
981
|
-
source_value = source_params.get(mapping.source_param)
|
|
982
|
-
|
|
983
|
-
if source_value is None and mapping.default_value is not None:
|
|
984
|
-
source_value = mapping.default_value
|
|
985
|
-
|
|
986
|
-
if mapping.required and source_value is None:
|
|
987
|
-
raise ValueError(f"必需参数 {mapping.source_param} 未提供")
|
|
988
|
-
|
|
989
|
-
if source_value is not None:
|
|
990
|
-
if mapping.mapping_type == ParameterMappingType.DIRECT:
|
|
991
|
-
target_params[mapping.target_param] = source_value
|
|
992
|
-
elif mapping.mapping_type == ParameterMappingType.TRANSFORM:
|
|
993
|
-
if mapping.transform_function:
|
|
994
|
-
# 执行转换函数
|
|
995
|
-
transform_func = self.parameter_transformers.get(mapping.transform_function)
|
|
996
|
-
if transform_func:
|
|
997
|
-
exec(transform_func, globals())
|
|
998
|
-
target_value = locals().get(mapping.transform_function)(source_value, {})
|
|
999
|
-
target_params[mapping.target_param] = target_value
|
|
1000
|
-
else:
|
|
1001
|
-
target_params[mapping.target_param] = source_value
|
|
1002
|
-
elif mapping.mapping_type == ParameterMappingType.IGNORE:
|
|
1003
|
-
continue
|
|
1004
|
-
elif mapping.mapping_type == ParameterMappingType.CUSTOM:
|
|
1005
|
-
# 自定义转换逻辑
|
|
1006
|
-
target_params[mapping.target_param] = self._custom_transform(
|
|
1007
|
-
source_value, mapping.source_param, mapping.target_param
|
|
1008
|
-
)
|
|
1009
|
-
|
|
1010
|
-
return target_params
|
|
1011
|
-
|
|
1012
|
-
def _custom_transform(self, value: Any, source_param: str, target_param: str) -> Any:
|
|
1013
|
-
"""自定义参数转换"""
|
|
1014
|
-
# 这里可以实现各种自定义转换逻辑
|
|
1015
|
-
if isinstance(value, str):
|
|
1016
|
-
# 字符串转换
|
|
1017
|
-
if "file" in target_param.lower():
|
|
1018
|
-
return str(value) if value else None
|
|
1019
|
-
elif "prompt" in target_param.lower():
|
|
1020
|
-
return value if value else ""
|
|
1021
|
-
|
|
1022
|
-
return value
|
|
1023
|
-
|
|
1024
|
-
def generate_cross_cli_command(self, source_cli: str, target_cli: str,
|
|
1025
|
-
task_description: str,
|
|
1026
|
-
parameters: Dict[str, Any]) -> Optional[str]:
|
|
1027
|
-
"""生成交叉CLI命令"""
|
|
1028
|
-
# 查找协作模式
|
|
1029
|
-
pattern = self.find_collaboration_pattern(source_cli, target_cli, CollaborationType.CODE_GENERATION)
|
|
1030
|
-
if not pattern:
|
|
1031
|
-
# 尝试找到最相关的协作模式
|
|
1032
|
-
for collab_type in CollaborationType:
|
|
1033
|
-
pattern = self.find_collaboration_pattern(source_cli, target_cli, collab_type)
|
|
1034
|
-
if pattern:
|
|
1035
|
-
break
|
|
1036
|
-
|
|
1037
|
-
if not pattern:
|
|
1038
|
-
return None
|
|
1039
|
-
|
|
1040
|
-
# 转换参数
|
|
1041
|
-
try:
|
|
1042
|
-
transformed_params = self.transform_parameters(pattern, parameters)
|
|
1043
|
-
except ValueError as e:
|
|
1044
|
-
return f"参数转换失败: {e}"
|
|
1045
|
-
|
|
1046
|
-
# 生成命令
|
|
1047
|
-
try:
|
|
1048
|
-
command = pattern.command_template.format(**transformed_params)
|
|
1049
|
-
return command
|
|
1050
|
-
except KeyError as e:
|
|
1051
|
-
return f"缺少必需参数: {e}"
|
|
1052
|
-
|
|
1053
|
-
def export_mapping_table(self, output_file: str) -> bool:
|
|
1054
|
-
"""导出映射表"""
|
|
1055
|
-
try:
|
|
1056
|
-
export_data = {
|
|
1057
|
-
'cli_compatibility': {},
|
|
1058
|
-
'collaboration_patterns': {},
|
|
1059
|
-
'parameter_transformers': self.parameter_transformers,
|
|
1060
|
-
'export_timestamp': datetime.now().isoformat(),
|
|
1061
|
-
'version': '1.0.0'
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
# 导出CLI兼容性
|
|
1065
|
-
for cli_name, compat in self.cli_compatibility.items():
|
|
1066
|
-
export_data['cli_compatibility'][cli_name] = {
|
|
1067
|
-
'supported_as_source': [ct.value for ct in compat.supported_as_source],
|
|
1068
|
-
'supported_as_target': [ct.value for ct in compat.supported_as_target],
|
|
1069
|
-
'strengths': compat.strengths,
|
|
1070
|
-
'limitations': compat.limitations,
|
|
1071
|
-
'preferred_contexts': compat.preferred_contexts
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
# 导出协作模式
|
|
1075
|
-
for pattern_id, pattern in self.collaboration_patterns.items():
|
|
1076
|
-
export_data['collaboration_patterns'][pattern_id] = {
|
|
1077
|
-
'source_cli': pattern.source_cli,
|
|
1078
|
-
'target_cli': pattern.target_cli,
|
|
1079
|
-
'collaboration_type': pattern.collaboration_type.value,
|
|
1080
|
-
'trigger_phrases': pattern.trigger_phrases,
|
|
1081
|
-
'command_template': pattern.command_template,
|
|
1082
|
-
'parameter_mappings': [
|
|
1083
|
-
{
|
|
1084
|
-
'source_param': pm.source_param,
|
|
1085
|
-
'target_param': pm.target_param,
|
|
1086
|
-
'mapping_type': pm.mapping_type.value,
|
|
1087
|
-
'transform_function': pm.transform_function,
|
|
1088
|
-
'default_value': pm.default_value,
|
|
1089
|
-
'required': pm.required,
|
|
1090
|
-
'description': pm.description
|
|
1091
|
-
}
|
|
1092
|
-
for pm in pattern.parameter_mappings
|
|
1093
|
-
],
|
|
1094
|
-
'output_format': pattern.output_format,
|
|
1095
|
-
'use_cases': pattern.use_cases,
|
|
1096
|
-
'best_practices': pattern.best_practices
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
# 写入文件
|
|
1100
|
-
output_path = Path(output_file)
|
|
1101
|
-
with open(output_path, 'w', encoding='utf-8') as f:
|
|
1102
|
-
json.dump(export_data, f, indent=2, ensure_ascii=False)
|
|
1103
|
-
|
|
1104
|
-
return True
|
|
1105
|
-
|
|
1106
|
-
except Exception as e:
|
|
1107
|
-
print(f"导出映射表失败: {e}")
|
|
1108
|
-
return False
|
|
1109
|
-
|
|
1110
|
-
def main():
|
|
1111
|
-
"""主函数"""
|
|
1112
|
-
from datetime import datetime
|
|
1113
|
-
|
|
1114
|
-
print("🔗 跨CLI协作映射表生成器")
|
|
1115
|
-
print("=" * 50)
|
|
1116
|
-
|
|
1117
|
-
# 创建映射器
|
|
1118
|
-
mapper = CrossCLIMapper()
|
|
1119
|
-
|
|
1120
|
-
# 导出映射表
|
|
1121
|
-
print("📋 导出协作映射表...")
|
|
1122
|
-
output_files = [
|
|
1123
|
-
'global_memory/cross_cli_mapping.json',
|
|
1124
|
-
'global_memory/cross_cli_mapping.md'
|
|
1125
|
-
]
|
|
1126
|
-
|
|
1127
|
-
# 导出JSON格式
|
|
1128
|
-
if mapper.export_mapping_table(output_files[0]):
|
|
1129
|
-
print(f" ✅ JSON映射表已导出: {output_files[0]}")
|
|
1130
|
-
else:
|
|
1131
|
-
print(f" ❌ JSON映射表导出失败")
|
|
1132
|
-
|
|
1133
|
-
# 生成协作建议示例
|
|
1134
|
-
print("\n💡 协作建议示例:")
|
|
1135
|
-
|
|
1136
|
-
sample_tasks = [
|
|
1137
|
-
"请帮我审查这段Python代码的安全性",
|
|
1138
|
-
"我想优化这个算法的性能",
|
|
1139
|
-
"帮我为这个项目生成技术文档",
|
|
1140
|
-
"设计一个自动化的CI/CD工作流"
|
|
1141
|
-
]
|
|
1142
|
-
|
|
1143
|
-
available_clis = list(mapper.cli_compatibility.keys())
|
|
1144
|
-
|
|
1145
|
-
for task in sample_tasks:
|
|
1146
|
-
suggestions = mapper.suggest_optimal_collaboration(task, available_clis)
|
|
1147
|
-
print(f"\n📝 任务: {task}")
|
|
1148
|
-
if suggestions:
|
|
1149
|
-
print(" 💡 推荐协作:")
|
|
1150
|
-
for source, target, score in suggestions[:3]:
|
|
1151
|
-
compat = mapper.get_cli_compatibility(target)
|
|
1152
|
-
if compat:
|
|
1153
|
-
primary_strength = compat.strengths[0] if compat.strengths else "综合能力"
|
|
1154
|
-
print(f" {source} → {target} (匹配度: {score:.2f}) - {primary_strength}")
|
|
1155
|
-
else:
|
|
1156
|
-
print(" ⚠️ 暂无合适协作建议")
|
|
1157
|
-
|
|
1158
|
-
print(f"\n📁 映射表文件已保存到: global_memory/")
|
|
1159
|
-
print("🎯 跨CLI协作系统就绪!")
|
|
1160
|
-
|
|
1161
|
-
return 0
|
|
1162
|
-
|
|
1163
|
-
if __name__ == "__main__":
|
|
1164
|
-
import sys
|
|
1165
|
-
sys.exit(main())
|