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.
Files changed (102) hide show
  1. package/README.en.md +306 -300
  2. package/README.md +469 -301
  3. package/package.json +97 -81
  4. package/scripts/publish.js +268 -0
  5. package/scripts/simple-publish.js +59 -0
  6. package/src/index.js +12 -0
  7. package/test/enhanced-main-alignment.test.js +298 -0
  8. package/test/hook-system-integration-test.js +307 -0
  9. package/test/natural-language-skills-test.js +320 -0
  10. package/test/nl-integration-test.js +179 -0
  11. package/test/parameter-parsing-test.js +143 -0
  12. package/test/real-test.js +435 -0
  13. package/test/system-compatibility-test.js +447 -0
  14. package/test/tdd-fixes-test.js +211 -0
  15. package/test/third-party-skills-test.js +321 -0
  16. package/test/tool-selection-integration-test.js +157 -0
  17. package/test/unit/cli-scanner.test.js +291 -0
  18. package/test/unit/cross-cli-executor.test.js +399 -0
  19. package/src/adapters/claude/__init__.py +0 -13
  20. package/src/adapters/claude/claude_skills_integration.py +0 -609
  21. package/src/adapters/claude/hook_adapter.py +0 -663
  22. package/src/adapters/claude/install_claude_integration.py +0 -265
  23. package/src/adapters/claude/skills_hook_adapter.py +0 -841
  24. package/src/adapters/claude/standalone_claude_adapter.py +0 -384
  25. package/src/adapters/cline/__init__.py +0 -20
  26. package/src/adapters/cline/config.py +0 -108
  27. package/src/adapters/cline/install_cline_integration.py +0 -617
  28. package/src/adapters/cline/mcp_server.py +0 -713
  29. package/src/adapters/cline/standalone_cline_adapter.py +0 -459
  30. package/src/adapters/codebuddy/__init__.py +0 -13
  31. package/src/adapters/codebuddy/buddy_adapter.py +0 -1125
  32. package/src/adapters/codebuddy/install_codebuddy_integration.py +0 -279
  33. package/src/adapters/codebuddy/skills_hook_adapter.py +0 -672
  34. package/src/adapters/codebuddy/skills_integration.py +0 -395
  35. package/src/adapters/codebuddy/standalone_codebuddy_adapter.py +0 -403
  36. package/src/adapters/codex/__init__.py +0 -11
  37. package/src/adapters/codex/base.py +0 -46
  38. package/src/adapters/codex/install_codex_integration.py +0 -311
  39. package/src/adapters/codex/mcp_server.py +0 -493
  40. package/src/adapters/codex/natural_language_parser.py +0 -82
  41. package/src/adapters/codex/slash_command_adapter.py +0 -326
  42. package/src/adapters/codex/standalone_codex_adapter.py +0 -362
  43. package/src/adapters/copilot/__init__.py +0 -13
  44. package/src/adapters/copilot/install_copilot_integration.py +0 -564
  45. package/src/adapters/copilot/mcp_adapter.py +0 -772
  46. package/src/adapters/copilot/mcp_server.py +0 -168
  47. package/src/adapters/copilot/standalone_copilot_adapter.py +0 -114
  48. package/src/adapters/gemini/__init__.py +0 -13
  49. package/src/adapters/gemini/extension_adapter.py +0 -690
  50. package/src/adapters/gemini/install_gemini_integration.py +0 -257
  51. package/src/adapters/gemini/standalone_gemini_adapter.py +0 -366
  52. package/src/adapters/iflow/__init__.py +0 -7
  53. package/src/adapters/iflow/hook_adapter.py +0 -1038
  54. package/src/adapters/iflow/hook_installer.py +0 -536
  55. package/src/adapters/iflow/install_iflow_integration.py +0 -271
  56. package/src/adapters/iflow/official_hook_adapter.py +0 -1272
  57. package/src/adapters/iflow/standalone_iflow_adapter.py +0 -48
  58. package/src/adapters/iflow/workflow_adapter.py +0 -793
  59. package/src/adapters/qoder/hook_installer.py +0 -732
  60. package/src/adapters/qoder/install_qoder_integration.py +0 -265
  61. package/src/adapters/qoder/notification_hook_adapter.py +0 -863
  62. package/src/adapters/qoder/standalone_qoder_adapter.py +0 -48
  63. package/src/adapters/qwen/__init__.py +0 -17
  64. package/src/adapters/qwencode/__init__.py +0 -13
  65. package/src/adapters/qwencode/inheritance_adapter.py +0 -818
  66. package/src/adapters/qwencode/install_qwencode_integration.py +0 -276
  67. package/src/adapters/qwencode/standalone_qwencode_adapter.py +0 -399
  68. package/src/atomic_collaboration_handler.py +0 -461
  69. package/src/cli_collaboration_agent.py +0 -697
  70. package/src/collaboration/hooks.py +0 -315
  71. package/src/core/__init__.py +0 -21
  72. package/src/core/ai_environment_scanner.py +0 -331
  73. package/src/core/base_adapter.py +0 -220
  74. package/src/core/cli_hook_integration.py +0 -406
  75. package/src/core/cross_cli_executor.py +0 -713
  76. package/src/core/cross_cli_mapping.py +0 -1165
  77. package/src/core/cross_platform_encoding.py +0 -365
  78. package/src/core/cross_platform_safe_cli.py +0 -894
  79. package/src/core/direct_cli_executor.py +0 -805
  80. package/src/core/direct_cli_hook_system.py +0 -958
  81. package/src/core/enhanced_init_processor.py +0 -467
  82. package/src/core/graceful_cli_executor.py +0 -912
  83. package/src/core/md_enhancer.py +0 -342
  84. package/src/core/md_generator.py +0 -619
  85. package/src/core/models.py +0 -218
  86. package/src/core/parser.py +0 -108
  87. package/src/core/real_cli_hook_system.py +0 -852
  88. package/src/core/real_cross_cli_system.py +0 -925
  89. package/src/core/verified_cross_cli_system.py +0 -961
  90. package/src/deploy.js +0 -737
  91. package/src/enhanced-main.js +0 -626
  92. package/src/enhanced_deploy.js +0 -303
  93. package/src/enhanced_universal_cli_setup.py +0 -930
  94. package/src/kimi_wrapper.py +0 -104
  95. package/src/main.js +0 -1309
  96. package/src/shell_integration.py +0 -398
  97. package/src/simple-main.js +0 -315
  98. package/src/smart_router_creator.py +0 -323
  99. package/src/universal_cli_setup.py +0 -1289
  100. package/src/utils/__init__.py +0 -12
  101. package/src/utils/cli_detector.py +0 -445
  102. package/src/utils/file_utils.py +0 -246
@@ -1,536 +0,0 @@
1
- """
2
- iFlow CLI Hook安装器
3
- 用于自动安装和配置iFlow CLI的Hook插件
4
- """
5
-
6
- import os
7
- import sys
8
- import shutil
9
- import json
10
- import yaml
11
- import logging
12
- from pathlib import Path
13
- from typing import Dict, Any, List, Optional
14
- from datetime import datetime
15
-
16
- logger = logging.getLogger(__name__)
17
-
18
-
19
- class IFlowHookInstaller:
20
- """iFlow CLI Hook安装器"""
21
-
22
- def __init__(self):
23
- """初始化安装器"""
24
- self.iflow_config_dir = os.path.expanduser("~/.config/iflow")
25
- self.hooks_config_file = os.path.join(self.iflow_config_dir, "hooks.yml")
26
- self.adapters_dir = os.path.join(self.iflow_config_dir, "adapters")
27
- self.workflows_dir = os.path.join(self.iflow_config_dir, "workflows")
28
- self.logs_dir = os.path.join(self.iflow_config_dir, "logs")
29
-
30
- # 适配器路径
31
- self.current_dir = Path(__file__).parent
32
- self.hook_adapter_file = self.current_dir / "hook_adapter.py"
33
- self.config_file = self.current_dir / "config.json"
34
- self.hooks_config_file = self.current_dir / "hooks.yml"
35
-
36
- # 安装状态
37
- self.installation_log: List[Dict[str, Any]] = []
38
-
39
- async def install_hooks(self) -> bool:
40
- """
41
- 安装iFlow CLI Hook插件
42
-
43
- Returns:
44
- bool: 安装是否成功
45
- """
46
- try:
47
- logger.info("开始安装iFlow CLI Hook插件...")
48
-
49
- # 1. 检查环境
50
- if not await self._check_environment():
51
- logger.error("环境检查失败")
52
- return False
53
-
54
- # 2. 创建配置目录
55
- await self._create_directories()
56
-
57
- # 3. 复制适配器文件
58
- if not await self._install_adapter_files():
59
- logger.error("适配器文件安装失败")
60
- return False
61
-
62
- # 4. 配置Hook插件
63
- if not await self._configure_hooks():
64
- logger.error("Hook配置失败")
65
- return False
66
-
67
- # 5. 创建工作流文件
68
- if not await self._create_workflows():
69
- logger.error("工作流创建失败")
70
- return False
71
-
72
- # 6. 验证安装
73
- if not await self._verify_installation():
74
- logger.error("安装验证失败")
75
- return False
76
-
77
- logger.info("iFlow CLI Hook插件安装成功")
78
- await self._log_installation("success", "Hook插件安装成功")
79
- return True
80
-
81
- except Exception as e:
82
- logger.error(f"安装iFlow CLI Hook插件失败: {e}")
83
- await self._log_installation("error", f"安装失败: {str(e)}")
84
- return False
85
-
86
- async def uninstall_hooks(self) -> bool:
87
- """
88
- 卸载iFlow CLI Hook插件
89
-
90
- Returns:
91
- bool: 卸载是否成功
92
- """
93
- try:
94
- logger.info("开始卸载iFlow CLI Hook插件...")
95
-
96
- # 1. 备份配置
97
- await self._backup_configuration()
98
-
99
- # 2. 移除Hook配置
100
- if not await self._remove_hook_configuration():
101
- logger.error("Hook配置移除失败")
102
- return False
103
-
104
- # 3. 清理适配器文件
105
- await self._cleanup_adapter_files()
106
-
107
- logger.info("iFlow CLI Hook插件卸载成功")
108
- await self._log_installation("success", "Hook插件卸载成功")
109
- return True
110
-
111
- except Exception as e:
112
- logger.error(f"卸载iFlow CLI Hook插件失败: {e}")
113
- await self._log_installation("error", f"卸载失败: {str(e)}")
114
- return False
115
-
116
- async def _check_environment(self) -> bool:
117
- """
118
- 检查安装环境
119
-
120
- Returns:
121
- bool: 环境是否满足要求
122
- """
123
- try:
124
- # 检查Python版本
125
- if sys.version_info < (3, 8):
126
- logger.error("需要Python 3.8或更高版本")
127
- return False
128
-
129
- # 检查必要的文件是否存在
130
- required_files = [
131
- self.hook_adapter_file,
132
- self.config_file,
133
- self.hooks_config_file
134
- ]
135
-
136
- for file_path in required_files:
137
- if not file_path.exists():
138
- logger.error(f"必要文件不存在: {file_path}")
139
- return False
140
-
141
- # 检查依赖包
142
- try:
143
- import yaml
144
- import asyncio
145
- except ImportError as e:
146
- logger.error(f"缺少依赖包: {e}")
147
- return False
148
-
149
- logger.info("环境检查通过")
150
- return True
151
-
152
- except Exception as e:
153
- logger.error(f"环境检查失败: {e}")
154
- return False
155
-
156
- async def _create_directories(self) -> None:
157
- """创建必要的目录"""
158
- directories = [
159
- self.iflow_config_dir,
160
- self.adapters_dir,
161
- self.workflows_dir,
162
- self.logs_dir
163
- ]
164
-
165
- for directory in directories:
166
- os.makedirs(directory, exist_ok=True)
167
- logger.debug(f"创建目录: {directory}")
168
-
169
- async def _install_adapter_files(self) -> bool:
170
- """
171
- 安装适配器文件
172
-
173
- Returns:
174
- bool: 安装是否成功
175
- """
176
- try:
177
- # 复制Hook适配器到iFlow适配器目录
178
- adapter_dest = os.path.join(self.adapters_dir, "hook_adapter.py")
179
- shutil.copy2(self.hook_adapter_file, adapter_dest)
180
- logger.info(f"复制Hook适配器到: {adapter_dest}")
181
-
182
- # 复制配置文件
183
- config_dest = os.path.join(self.adapters_dir, "config.json")
184
- shutil.copy2(self.config_file, config_dest)
185
- logger.info(f"复制配置文件到: {config_dest}")
186
-
187
- # 创建__init__.py文件使其成为Python包
188
- init_file = os.path.join(self.adapters_dir, "__init__.py")
189
- if not os.path.exists(init_file):
190
- with open(init_file, 'w', encoding='utf-8') as f:
191
- f.write('"""iFlow CLI适配器包"""\n')
192
- logger.info(f"创建__init__.py文件: {init_file}")
193
-
194
- return True
195
-
196
- except Exception as e:
197
- logger.error(f"安装适配器文件失败: {e}")
198
- return False
199
-
200
- async def _configure_hooks(self) -> bool:
201
- """
202
- 配置Hook插件
203
-
204
- Returns:
205
- bool: 配置是否成功
206
- """
207
- try:
208
- # 读取现有的hooks配置
209
- existing_config = {}
210
- if os.path.exists(self.hooks_config_file):
211
- with open(self.hooks_config_file, 'r', encoding='utf-8') as f:
212
- existing_config = yaml.safe_load(f) or {}
213
-
214
- # 读取我们的hooks配置
215
- with open(self.hooks_config_file, 'r', encoding='utf-8') as f:
216
- hook_config = yaml.safe_load(f)
217
-
218
- # 合并配置
219
- merged_config = self._merge_hook_config(existing_config, hook_config)
220
-
221
- # 保存合并后的配置
222
- with open(self.hooks_config_file, 'w', encoding='utf-8') as f:
223
- yaml.dump(merged_config, f, default_flow_style=False, allow_unicode=True)
224
-
225
- logger.info(f"Hook配置已保存到: {self.hooks_config_file}")
226
- return True
227
-
228
- except Exception as e:
229
- logger.error(f"配置Hook失败: {e}")
230
- return False
231
-
232
- def _merge_hook_config(self, existing: Dict[str, Any], new: Dict[str, Any]) -> Dict[str, Any]:
233
- """
234
- 合并Hook配置
235
-
236
- Args:
237
- existing: 现有配置
238
- new: 新配置
239
-
240
- Returns:
241
- Dict[str, Any]: 合并后的配置
242
- """
243
- merged = existing.copy()
244
-
245
- # 合并plugins
246
- existing_plugins = merged.get('plugins', [])
247
- new_plugins = new.get('plugins', [])
248
-
249
- for new_plugin in new_plugins:
250
- # 检查是否已存在同名插件
251
- existing_plugin = next(
252
- (p for p in existing_plugins if p.get('name') == new_plugin.get('name')),
253
- None
254
- )
255
-
256
- if existing_plugin:
257
- # 更新现有插件
258
- existing_plugin.update(new_plugin)
259
- else:
260
- # 添加新插件
261
- existing_plugins.append(new_plugin)
262
-
263
- merged['plugins'] = existing_plugins
264
-
265
- # 合并其他配置
266
- for key, value in new.items():
267
- if key != 'plugins':
268
- merged[key] = value
269
-
270
- return merged
271
-
272
- async def _create_workflows(self) -> bool:
273
- """
274
- 创建工作流文件
275
-
276
- Returns:
277
- bool: 创建是否成功
278
- """
279
- try:
280
- # 创建跨CLI集成工作流
281
- workflow_config = {
282
- "name": "cross-cli-integration",
283
- "description": "跨CLI工具集成工作流",
284
- "version": "1.0",
285
- "stages": [
286
- {
287
- "name": "input_processing",
288
- "description": "输入处理和意图检测",
289
- "type": "python",
290
- "required": True,
291
- "timeout": 10
292
- },
293
- {
294
- "name": "cross_cli_execution",
295
- "description": "跨CLI调用执行",
296
- "type": "python",
297
- "required": False,
298
- "timeout": 30
299
- },
300
- {
301
- "name": "result_processing",
302
- "description": "结果处理和格式化",
303
- "type": "python",
304
- "required": True,
305
- "timeout": 15
306
- }
307
- ],
308
- "hooks": {
309
- "hooks_enabled": True,
310
- "hook_file": "~/.config/iflow/hooks.yml"
311
- }
312
- }
313
-
314
- workflow_file = os.path.join(self.workflows_dir, "cross_cli_integration.json")
315
- with open(workflow_file, 'w', encoding='utf-8') as f:
316
- json.dump(workflow_config, f, indent=2, ensure_ascii=False)
317
-
318
- logger.info(f"创建工作流文件: {workflow_file}")
319
- return True
320
-
321
- except Exception as e:
322
- logger.error(f"创建工作流失败: {e}")
323
- return False
324
-
325
- async def _verify_installation(self) -> bool:
326
- """
327
- 验证安装
328
-
329
- Returns:
330
- bool: 验证是否成功
331
- """
332
- try:
333
- # 检查文件是否存在
334
- required_files = [
335
- self.hooks_config_file,
336
- os.path.join(self.adapters_dir, "hook_adapter.py"),
337
- os.path.join(self.adapters_dir, "config.json"),
338
- os.path.join(self.workflows_dir, "cross_cli_integration.json")
339
- ]
340
-
341
- for file_path in required_files:
342
- if not os.path.exists(file_path):
343
- logger.error(f"必要文件不存在: {file_path}")
344
- return False
345
-
346
- # 检查配置格式
347
- with open(self.hooks_config_file, 'r', encoding='utf-8') as f:
348
- hook_config = yaml.safe_load(f)
349
-
350
- if not hook_config or 'plugins' not in hook_config:
351
- logger.error("Hook配置格式错误")
352
- return False
353
-
354
- # 检查我们的插件是否存在
355
- plugins = hook_config.get('plugins', [])
356
- cross_cli_plugin = next(
357
- (p for p in plugins if p.get('name') == 'cross-cli-adapter'),
358
- None
359
- )
360
-
361
- if not cross_cli_plugin:
362
- logger.error("跨CLI适配器插件未找到")
363
- return False
364
-
365
- logger.info("安装验证通过")
366
- return True
367
-
368
- except Exception as e:
369
- logger.error(f"安装验证失败: {e}")
370
- return False
371
-
372
- async def _backup_configuration(self) -> None:
373
- """备份现有配置"""
374
- try:
375
- if os.path.exists(self.hooks_config_file):
376
- timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
377
- backup_file = f"{self.hooks_config_file}.backup_{timestamp}"
378
- shutil.copy2(self.hooks_config_file, backup_file)
379
- logger.info(f"配置已备份到: {backup_file}")
380
- except Exception as e:
381
- logger.warning(f"备份配置失败: {e}")
382
-
383
- async def _remove_hook_configuration(self) -> bool:
384
- """
385
- 移除Hook配置
386
-
387
- Returns:
388
- bool: 移除是否成功
389
- """
390
- try:
391
- if not os.path.exists(self.hooks_config_file):
392
- return True
393
-
394
- # 读取现有配置
395
- with open(self.hooks_config_file, 'r', encoding='utf-8') as f:
396
- config = yaml.safe_load(f) or {}
397
-
398
- # 移除我们的插件
399
- plugins = config.get('plugins', [])
400
- plugins = [p for p in plugins if p.get('name') != 'cross-cli-adapter']
401
- config['plugins'] = plugins
402
-
403
- # 保存配置
404
- with open(self.hooks_config_file, 'w', encoding='utf-8') as f:
405
- yaml.dump(config, f, default_flow_style=False, allow_unicode=True)
406
-
407
- logger.info("Hook配置已移除")
408
- return True
409
-
410
- except Exception as e:
411
- logger.error(f"移除Hook配置失败: {e}")
412
- return False
413
-
414
- async def _cleanup_adapter_files(self) -> None:
415
- """清理适配器文件"""
416
- try:
417
- files_to_remove = [
418
- os.path.join(self.adapters_dir, "hook_adapter.py"),
419
- os.path.join(self.adapters_dir, "config.json"),
420
- os.path.join(self.workflows_dir, "cross_cli_integration.json")
421
- ]
422
-
423
- for file_path in files_to_remove:
424
- if os.path.exists(file_path):
425
- os.remove(file_path)
426
- logger.debug(f"删除文件: {file_path}")
427
-
428
- except Exception as e:
429
- logger.warning(f"清理适配器文件失败: {e}")
430
-
431
- async def _log_installation(self, status: str, message: str) -> None:
432
- """
433
- 记录安装日志
434
-
435
- Args:
436
- status: 状态
437
- message: 消息
438
- """
439
- log_entry = {
440
- 'timestamp': datetime.now().isoformat(),
441
- 'status': status,
442
- 'message': message
443
- }
444
- self.installation_log.append(log_entry)
445
-
446
- # 写入日志文件
447
- log_file = os.path.join(self.logs_dir, "installation.log")
448
- os.makedirs(os.path.dirname(log_file), exist_ok=True)
449
-
450
- try:
451
- with open(log_file, 'a', encoding='utf-8') as f:
452
- f.write(f"{json.dumps(log_entry, ensure_ascii=False)}\n")
453
- except Exception as e:
454
- logger.warning(f"写入安装日志失败: {e}")
455
-
456
- def get_installation_status(self) -> Dict[str, Any]:
457
- """
458
- 获取安装状态
459
-
460
- Returns:
461
- Dict[str, Any]: 安装状态
462
- """
463
- return {
464
- 'iflow_config_dir': self.iflow_config_dir,
465
- 'hooks_config_file': self.hooks_config_file,
466
- 'files_exist': {
467
- 'hook_adapter': os.path.exists(os.path.join(self.adapters_dir, "hook_adapter.py")),
468
- 'config': os.path.exists(os.path.join(self.adapters_dir, "config.json")),
469
- 'hooks_config': os.path.exists(self.hooks_config_file),
470
- 'workflow': os.path.exists(os.path.join(self.workflows_dir, "cross_cli_integration.json"))
471
- },
472
- 'installation_log': self.installation_log
473
- }
474
-
475
-
476
- # 便捷函数
477
- async def install_iflow_hooks() -> bool:
478
- """
479
- 安装iFlow CLI Hook插件
480
-
481
- Returns:
482
- bool: 安装是否成功
483
- """
484
- installer = IFlowHookInstaller()
485
- return await installer.install_hooks()
486
-
487
-
488
- async def uninstall_iflow_hooks() -> bool:
489
- """
490
- 卸载iFlow CLI Hook插件
491
-
492
- Returns:
493
- bool: 卸载是否成功
494
- """
495
- installer = IFlowHookInstaller()
496
- return await installer.uninstall_hooks()
497
-
498
-
499
- def get_iflow_hook_status() -> Dict[str, Any]:
500
- """
501
- 获取iFlow Hook插件状态
502
-
503
- Returns:
504
- Dict[str, Any]: 状态信息
505
- """
506
- installer = IFlowHookInstaller()
507
- return installer.get_installation_status()
508
-
509
-
510
- if __name__ == "__main__":
511
- import asyncio
512
-
513
- async def main():
514
- """主函数"""
515
- import sys
516
-
517
- if len(sys.argv) < 2:
518
- print("用法: python hook_installer.py [install|uninstall|status]")
519
- return
520
-
521
- command = sys.argv[1].lower()
522
-
523
- if command == "install":
524
- success = await install_iflow_hooks()
525
- print(f"安装{'成功' if success else '失败'}")
526
- elif command == "uninstall":
527
- success = await uninstall_iflow_hooks()
528
- print(f"卸载{'成功' if success else '失败'}")
529
- elif command == "status":
530
- status = get_iflow_hook_status()
531
- print("iFlow Hook插件状态:")
532
- print(json.dumps(status, indent=2, ensure_ascii=False))
533
- else:
534
- print("未知命令:", command)
535
-
536
- asyncio.run(main())