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,265 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Claude CLI Hook集成安装脚本
|
|
3
|
+
为Claude CLI安装跨CLI协作感知能力
|
|
4
|
+
|
|
5
|
+
使用方法:
|
|
6
|
+
python install_claude_integration.py [--verify|--uninstall]
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
import json
|
|
12
|
+
import shutil
|
|
13
|
+
import argparse
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
|
|
17
|
+
# 获取当前文件目录
|
|
18
|
+
current_dir = Path(__file__).parent
|
|
19
|
+
project_root = current_dir.parent.parent.parent
|
|
20
|
+
|
|
21
|
+
# Claude CLI配置路径
|
|
22
|
+
CLAUDE_CONFIG_DIR = os.path.expanduser("~/.config/claude")
|
|
23
|
+
CLAUDE_HOOKS_FILE = os.path.join(CLAUDE_CONFIG_DIR, "hooks.json")
|
|
24
|
+
|
|
25
|
+
def create_claude_config_directory():
|
|
26
|
+
"""创建Claude配置目录"""
|
|
27
|
+
os.makedirs(CLAUDE_CONFIG_DIR, exist_ok=True)
|
|
28
|
+
print(f"[OK] 创建Claude配置目录: {CLAUDE_CONFIG_DIR}")
|
|
29
|
+
|
|
30
|
+
def install_claude_hooks():
|
|
31
|
+
"""安装Claude Hook配置"""
|
|
32
|
+
# 读取现有hooks配置
|
|
33
|
+
existing_hooks = {}
|
|
34
|
+
if os.path.exists(CLAUDE_HOOKS_FILE):
|
|
35
|
+
try:
|
|
36
|
+
with open(CLAUDE_HOOKS_FILE, 'r', encoding='utf-8') as f:
|
|
37
|
+
existing_hooks = json.load(f)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
print(f"⚠️ 读取现有hooks配置失败: {e}")
|
|
40
|
+
existing_hooks = {}
|
|
41
|
+
|
|
42
|
+
# 定义跨CLI协作的Hook配置
|
|
43
|
+
cross_cli_hooks = {
|
|
44
|
+
"user_prompt_submit": {
|
|
45
|
+
"module": "src.adapters.claude.hook_adapter",
|
|
46
|
+
"class": "ClaudeHookAdapter",
|
|
47
|
+
"enabled": True,
|
|
48
|
+
"priority": 100,
|
|
49
|
+
"config": {
|
|
50
|
+
"cross_cli_enabled": True,
|
|
51
|
+
"supported_clis": ["gemini", "qwencode", "iflow", "qoder", "codebuddy", "copilot"],
|
|
52
|
+
"auto_detect": True,
|
|
53
|
+
"timeout": 30
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"tool_use_pre": {
|
|
57
|
+
"module": "src.adapters.claude.hook_adapter",
|
|
58
|
+
"class": "ClaudeHookAdapter",
|
|
59
|
+
"enabled": True,
|
|
60
|
+
"priority": 90,
|
|
61
|
+
"config": {
|
|
62
|
+
"cross_cli_enabled": True,
|
|
63
|
+
"log_requests": True
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"response_generated": {
|
|
67
|
+
"module": "src.adapters.claude.hook_adapter",
|
|
68
|
+
"class": "ClaudeHookAdapter",
|
|
69
|
+
"enabled": True,
|
|
70
|
+
"priority": 85,
|
|
71
|
+
"config": {
|
|
72
|
+
"add_collaboration_header": True,
|
|
73
|
+
"format_cross_cli_results": True
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# 合并配置(保留现有配置,添加协作功能)
|
|
79
|
+
merged_hooks = existing_hooks.copy()
|
|
80
|
+
for hook_name, hook_config in cross_cli_hooks.items():
|
|
81
|
+
merged_hooks[hook_name] = hook_config
|
|
82
|
+
|
|
83
|
+
# 写入hooks配置文件
|
|
84
|
+
try:
|
|
85
|
+
with open(CLADE_HOOKS_FILE, 'w', encoding='utf-8') as f:
|
|
86
|
+
json.dump(merged_hooks, f, indent=2, ensure_ascii=False)
|
|
87
|
+
|
|
88
|
+
print(f"[OK] Claude Hook配置已安装: {CLAUDE_HOOKS_FILE}")
|
|
89
|
+
print("🔗 已安装的Hook:")
|
|
90
|
+
for hook_name in cross_cli_hooks.keys():
|
|
91
|
+
print(f" - {hook_name}: [OK] 跨CLI协作感知")
|
|
92
|
+
|
|
93
|
+
return True
|
|
94
|
+
except Exception as e:
|
|
95
|
+
print(f"❌ 安装Claude Hook配置失败: {e}")
|
|
96
|
+
return False
|
|
97
|
+
|
|
98
|
+
def copy_adapter_file():
|
|
99
|
+
"""复制适配器文件到Claude配置目录"""
|
|
100
|
+
try:
|
|
101
|
+
# 创建适配器目录
|
|
102
|
+
adapter_dir = os.path.join(CLAUDE_CONFIG_DIR, "adapters")
|
|
103
|
+
os.makedirs(adapter_dir, exist_ok=True)
|
|
104
|
+
|
|
105
|
+
# 复制适配器文件
|
|
106
|
+
adapter_files = [
|
|
107
|
+
"hook_adapter.py",
|
|
108
|
+
"claude_skills_integration.py",
|
|
109
|
+
"skills_hook_adapter.py"
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
for file_name in adapter_files:
|
|
113
|
+
src_file = current_dir / file_name
|
|
114
|
+
dst_file = os.path.join(adapter_dir, file_name)
|
|
115
|
+
|
|
116
|
+
if src_file.exists():
|
|
117
|
+
shutil.copy2(src_file, dst_file)
|
|
118
|
+
print(f"[OK] 复制适配器文件: {file_name}")
|
|
119
|
+
else:
|
|
120
|
+
print(f"⚠️ 适配器文件不存在: {file_name}")
|
|
121
|
+
|
|
122
|
+
return True
|
|
123
|
+
except Exception as e:
|
|
124
|
+
print(f"❌ 复制适配器文件失败: {e}")
|
|
125
|
+
return False
|
|
126
|
+
|
|
127
|
+
def verify_installation():
|
|
128
|
+
"""验证安装是否成功"""
|
|
129
|
+
print("\n🔍 验证Claude CLI集成安装...")
|
|
130
|
+
|
|
131
|
+
# 检查配置目录
|
|
132
|
+
if not os.path.exists(CLAUDE_CONFIG_DIR):
|
|
133
|
+
print(f"❌ 配置目录不存在: {CLAUDE_CONFIG_DIR}")
|
|
134
|
+
return False
|
|
135
|
+
|
|
136
|
+
# 检查hooks文件
|
|
137
|
+
if not os.path.exists(CLAUDE_HOOKS_FILE):
|
|
138
|
+
print(f"❌ Hooks配置文件不存在: {CLAUDE_HOOKS_FILE}")
|
|
139
|
+
return False
|
|
140
|
+
|
|
141
|
+
# 检查适配器文件
|
|
142
|
+
adapter_dir = os.path.join(CLADE_CONFIG_DIR, "adapters")
|
|
143
|
+
if not os.path.exists(adapter_dir):
|
|
144
|
+
print(f"❌ 适配器目录不存在: {adapter_dir}")
|
|
145
|
+
return False
|
|
146
|
+
|
|
147
|
+
# 读取并验证hooks配置
|
|
148
|
+
try:
|
|
149
|
+
with open(CLAUDE_HOOKS_FILE, 'r', encoding='utf-8') as f:
|
|
150
|
+
hooks_config = json.load(f)
|
|
151
|
+
|
|
152
|
+
required_hooks = ["user_prompt_submit", "tool_use_pre", "response_generated"]
|
|
153
|
+
for hook in required_hooks:
|
|
154
|
+
if hook in hooks_config:
|
|
155
|
+
hook_config = hooks_config[hook]
|
|
156
|
+
if hook_config.get("enabled", False):
|
|
157
|
+
print(f"[OK] Hook {hook}: 已启用")
|
|
158
|
+
else:
|
|
159
|
+
print(f"⚠️ Hook {hook}: 未启用")
|
|
160
|
+
else:
|
|
161
|
+
print(f"❌ 缺少必需Hook: {hook}")
|
|
162
|
+
return False
|
|
163
|
+
|
|
164
|
+
return True
|
|
165
|
+
except Exception as e:
|
|
166
|
+
print(f"❌ 验证配置失败: {e}")
|
|
167
|
+
return False
|
|
168
|
+
|
|
169
|
+
def uninstall_claude_integration():
|
|
170
|
+
"""卸载Claude CLI集成"""
|
|
171
|
+
try:
|
|
172
|
+
# 备份现有配置
|
|
173
|
+
if os.path.exists(CLAUDE_HOOKS_FILE):
|
|
174
|
+
backup_file = f"{CLAUDE_HOOKS_FILE}.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
|
175
|
+
shutil.copy2(CLAUDE_HOOKS_FILE, backup_file)
|
|
176
|
+
print(f"📦 已备份现有配置: {backup_file}")
|
|
177
|
+
|
|
178
|
+
# 移除适配器目录
|
|
179
|
+
adapter_dir = os.path.join(CLAUDE_CONFIG_DIR, "adapters")
|
|
180
|
+
if os.path.exists(adapter_dir):
|
|
181
|
+
shutil.rmtree(adapter_dir)
|
|
182
|
+
print(f"🗑️ 已删除适配器目录: {adapter_dir}")
|
|
183
|
+
|
|
184
|
+
print("[OK] Claude CLI集成已卸载")
|
|
185
|
+
return True
|
|
186
|
+
except Exception as e:
|
|
187
|
+
print(f"❌ 卸载失败: {e}")
|
|
188
|
+
return False
|
|
189
|
+
|
|
190
|
+
def main():
|
|
191
|
+
parser = argparse.ArgumentParser(
|
|
192
|
+
description="Claude CLI跨CLI协作集成安装脚本",
|
|
193
|
+
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
parser.add_argument(
|
|
197
|
+
"--install",
|
|
198
|
+
action="store_true",
|
|
199
|
+
help="安装Claude CLI跨CLI协作集成"
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
parser.add_argument(
|
|
203
|
+
"--verify",
|
|
204
|
+
action="store_true",
|
|
205
|
+
help="验证Claude CLI集成安装"
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
parser.add_argument(
|
|
209
|
+
"--uninstall",
|
|
210
|
+
action="store_true",
|
|
211
|
+
help="卸载Claude CLI跨CLI协作集成"
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
args = parser.parse_args()
|
|
215
|
+
|
|
216
|
+
print("[INSTALL] Claude CLI跨CLI协作集成安装器")
|
|
217
|
+
print("=" * 50)
|
|
218
|
+
|
|
219
|
+
if args.uninstall:
|
|
220
|
+
print("[UNINSTALL] 卸载模式...")
|
|
221
|
+
success = uninstall_claude_integration()
|
|
222
|
+
elif args.verify:
|
|
223
|
+
print("[VERIFY] 验证模式...")
|
|
224
|
+
success = verify_installation()
|
|
225
|
+
elif args.install or len(sys.argv) == 1:
|
|
226
|
+
print("[INSTALL] 安装模式...")
|
|
227
|
+
print("\n[INFO] 为Claude CLI安装跨CLI协作感知能力")
|
|
228
|
+
print("这将让Claude CLI能够:")
|
|
229
|
+
print(" - 检测跨CLI调用意图 (如: '请用gemini帮我分析')")
|
|
230
|
+
print(" - 自动路由到目标CLI工具")
|
|
231
|
+
print(" - 格式化协作结果")
|
|
232
|
+
print(" - 与其他CLI工具间接协作")
|
|
233
|
+
|
|
234
|
+
# 1. 创建配置目录
|
|
235
|
+
print("\n1️⃣ 创建配置目录...")
|
|
236
|
+
create_claude_config_directory()
|
|
237
|
+
|
|
238
|
+
# 2. 安装Hook配置
|
|
239
|
+
print("\nStep 2. 安装Hook配置...")
|
|
240
|
+
hooks_success = install_claude_hooks()
|
|
241
|
+
|
|
242
|
+
# 3. 复制适配器文件
|
|
243
|
+
print("\nStep 3. 复制适配器文件...")
|
|
244
|
+
adapter_success = copy_adapter_file()
|
|
245
|
+
|
|
246
|
+
success = hooks_success and adapter_success
|
|
247
|
+
|
|
248
|
+
if success:
|
|
249
|
+
print("\n🎉 Claude CLI集成安装成功!")
|
|
250
|
+
print("\n[INFO] 安装摘要:")
|
|
251
|
+
print(f" [OK] 配置目录: {CLAUDE_CONFIG_DIR}")
|
|
252
|
+
print(f" [OK] Hooks文件: {CLAUDE_HOOKS_FILE}")
|
|
253
|
+
print(" [OK] 跨CLI协作感知: 已启用")
|
|
254
|
+
|
|
255
|
+
print("\n[INSTALL] 下一步:")
|
|
256
|
+
print(" 1. 安装其他CLI工具的集成")
|
|
257
|
+
print(" 2. 运行: ai-cli-router init")
|
|
258
|
+
print(" 3. 开始使用: claude-cli '请用gemini帮我分析代码'")
|
|
259
|
+
else:
|
|
260
|
+
print("\n❌ Claude CLI集成安装失败,请检查错误信息")
|
|
261
|
+
else:
|
|
262
|
+
parser.print_help()
|
|
263
|
+
|
|
264
|
+
if __name__ == "__main__":
|
|
265
|
+
main()
|