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,398 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- Shell集成模块 - 将CLI工具集成到shell环境中
5
- 支持各种shell的参数传递和命令执行
6
- """
7
-
8
- import os
9
- import sys
10
- import subprocess
11
- import json
12
- from pathlib import Path
13
- from typing import Dict, List, Optional, Any
14
-
15
-
16
- class ShellIntegration:
17
- """Shell集成类"""
18
-
19
- def __init__(self):
20
- self.script_dir = Path(__file__).parent
21
- self.cli_script = self.script_dir / 'iflow_cli.py'
22
- self.hook_script = self.script_dir / 'cli_intents_hook.py'
23
- self.shell_configs = self._get_shell_configs()
24
-
25
- def _get_shell_configs(self) -> Dict[str, Dict]:
26
- """获取各种shell的配置"""
27
- return {
28
- "bash": {
29
- "rc_file": "~/.bashrc",
30
- "profile_file": "~/.bash_profile",
31
- "alias_template": "alias {name}='python {script}'",
32
- "function_template": """
33
- {name}() {{
34
- python {hook_script} "$@"
35
- }}
36
- """
37
- },
38
- "zsh": {
39
- "rc_file": "~/.zshrc",
40
- "profile_file": "~/.zprofile",
41
- "alias_template": "alias {name}='python {script}'",
42
- "function_template": """
43
- {name}() {{
44
- python {hook_script} "$@"
45
- }}
46
- """
47
- },
48
- "fish": {
49
- "rc_file": "~/.config/fish/config.fish",
50
- "alias_template": "alias {name} 'python {script}'",
51
- "function_template": """
52
- function {name}
53
- python {hook_script} $argv
54
- end
55
- """
56
- },
57
- "powershell": {
58
- "profile_file": "~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1",
59
- "alias_template": "Set-Alias -Name {name} -Value 'python {script}'",
60
- "function_template": """
61
- function {name} {{
62
- python {hook_script} $args
63
- }}
64
- """
65
- },
66
- "cmd": {
67
- "batch_file": "%USERPROFILE%\\iflow_cli.bat",
68
- "template": """@echo off
69
- python "{script}" %*
70
- """
71
- }
72
- }
73
-
74
- def detect_shell(self) -> str:
75
- """检测当前使用的shell"""
76
- shell_env = os.environ.get('SHELL', '')
77
- if 'bash' in shell_env:
78
- return 'bash'
79
- elif 'zsh' in shell_env:
80
- return 'zsh'
81
- elif 'fish' in shell_env:
82
- return 'fish'
83
- elif sys.platform == 'win32':
84
- # Windows环境检测
85
- if 'POWERSHELL' in os.environ or 'PSModulePath' in os.environ:
86
- return 'powershell'
87
- else:
88
- return 'cmd'
89
- else:
90
- return 'bash' # 默认
91
-
92
- def install_shell_integration(self, shell_type: str = None, global_command: str = "ai") -> bool:
93
- """安装shell集成"""
94
- if shell_type is None:
95
- shell_type = self.detect_shell()
96
-
97
- if shell_type not in self.shell_configs:
98
- print(f"❌ 不支持的shell类型: {shell_type}")
99
- return False
100
-
101
- config = self.shell_configs[shell_type]
102
-
103
- try:
104
- if shell_type in ['bash', 'zsh']:
105
- return self._install_unix_shell(shell_type, config, global_command)
106
- elif shell_type == 'fish':
107
- return self._install_fish_shell(config, global_command)
108
- elif shell_type == 'powershell':
109
- return self._install_powershell(config, global_command)
110
- elif shell_type == 'cmd':
111
- return self._install_cmd_batch(config, global_command)
112
-
113
- except Exception as e:
114
- print(f"❌ 安装失败: {e}")
115
- return False
116
-
117
- def _install_unix_shell(self, shell_type: str, config: Dict, global_command: str) -> bool:
118
- """安装Unix shell (bash/zsh) 集成"""
119
- rc_file = Path(config["rc_file"]).expanduser()
120
-
121
- # 创建函数定义
122
- function_def = config["function_template"].format(
123
- name=global_command,
124
- hook_script=str(self.hook_script)
125
- )
126
-
127
- # 检查是否已经存在
128
- if rc_file.exists():
129
- content = rc_file.read_text(encoding='utf-8')
130
- if f"function {global_command}" in content or f"{global_command}()" in content:
131
- print(f"✅ {shell_type} 集成已存在")
132
- return True
133
-
134
- # 添加到配置文件
135
- with open(rc_file, 'a', encoding='utf-8') as f:
136
- f.write(f"\n# iFlow CLI Integration\n")
137
- f.write(function_def)
138
-
139
- print(f"✅ {shell_type} 集成安装成功")
140
- print(f"📝 配置文件: {rc_file}")
141
- print(f"🚀 使用: {global_command} '你的命令'")
142
- print(f"💡 重新加载shell或运行: source {rc_file}")
143
-
144
- return True
145
-
146
- def _install_fish_shell(self, config: Dict, global_command: str) -> bool:
147
- """安装Fish shell集成"""
148
- config_dir = Path(config["rc_file"]).parent
149
- config_dir.mkdir(parents=True, exist_ok=True)
150
-
151
- config_file = Path(config["rc_file"])
152
-
153
- # 创建函数定义
154
- function_def = config["function_template"].format(
155
- name=global_command,
156
- hook_script=str(self.hook_script)
157
- )
158
-
159
- # 检查是否已经存在
160
- if config_file.exists():
161
- content = config_file.read_text(encoding='utf-8')
162
- if f"function {global_command}" in content:
163
- print("✅ Fish 集成已存在")
164
- return True
165
-
166
- # 添加到配置文件
167
- with open(config_file, 'a', encoding='utf-8') as f:
168
- f.write(f"\n# iFlow CLI Integration\n")
169
- f.write(function_def)
170
-
171
- print("✅ Fish 集成安装成功")
172
- print(f"📝 配置文件: {config_file}")
173
- print(f"🚀 使用: {global_command} '你的命令'")
174
-
175
- return True
176
-
177
- def _install_powershell(self, config: Dict, global_command: str) -> bool:
178
- """安装PowerShell集成"""
179
- profile_file = Path(config["profile_file"]).expanduser()
180
- profile_file.parent.mkdir(parents=True, exist_ok=True)
181
-
182
- # 创建函数定义
183
- function_def = config["function_template"].format(
184
- name=global_command,
185
- hook_script=str(self.hook_script)
186
- )
187
-
188
- # 检查是否已经存在
189
- if profile_file.exists():
190
- content = profile_file.read_text(encoding='utf-8')
191
- if f"function {global_command}" in content:
192
- print("✅ PowerShell 集成已存在")
193
- return True
194
-
195
- # 添加到配置文件
196
- with open(profile_file, 'a', encoding='utf-8') as f:
197
- f.write(f"\n# iFlow CLI Integration\n")
198
- f.write(function_def)
199
-
200
- print("✅ PowerShell 集成安装成功")
201
- print(f"📝 配置文件: {profile_file}")
202
- print(f"🚀 使用: {global_command} '你的命令'")
203
- print("💡 重新启动PowerShell以加载配置")
204
-
205
- return True
206
-
207
- def _install_cmd_batch(self, config: Dict, global_command: str) -> bool:
208
- """安装CMD批处理集成"""
209
- batch_file = Path(os.environ['USERPROFILE']) / f'{global_command}.bat'
210
-
211
- # 创建批处理文件
212
- batch_content = config["template"].format(
213
- script=str(self.hook_script)
214
- )
215
-
216
- with open(batch_file, 'w', encoding='utf-8') as f:
217
- f.write(batch_content)
218
-
219
- # 检查PATH环境变量
220
- user_profile = os.environ['USERPROFILE']
221
- if user_profile not in os.environ.get('PATH', ''):
222
- print(f"⚠️ 建议将 {user_profile} 添加到PATH环境变量")
223
-
224
- print("✅ CMD 集成安装成功")
225
- print(f"📝 批处理文件: {batch_file}")
226
- print(f"🚀 使用: {global_command} '你的命令'")
227
-
228
- return True
229
-
230
- def create_global_shortcuts(self, shortcuts: Dict[str, str]) -> bool:
231
- """创建全局快捷命令"""
232
- try:
233
- shell_type = self.detect_shell()
234
- config = self.shell_configs[shell_type]
235
-
236
- if shell_type in ['bash', 'zsh', 'fish']:
237
- rc_file = Path(config["rc_file"]).expanduser()
238
-
239
- with open(rc_file, 'a', encoding='utf-8') as f:
240
- f.write("\n# iFlow CLI Shortcuts\n")
241
- for shortcut, command in shortcuts.items():
242
- alias_def = config["alias_template"].format(
243
- name=shortcut,
244
- script=f"{self.cli_script} {command}"
245
- )
246
- f.write(f"{alias_def}\n")
247
-
248
- print(f"✅ 快捷命令已添加到 {rc_file}")
249
- return True
250
-
251
- elif shell_type == 'powershell':
252
- profile_file = Path(config["profile_file"]).expanduser()
253
-
254
- with open(profile_file, 'a', encoding='utf-8') as f:
255
- f.write("\n# iFlow CLI Shortcuts\n")
256
- for shortcut, command in shortcuts.items():
257
- alias_def = config["alias_template"].format(
258
- name=shortcut,
259
- script=f"{self.cli_script} {command}"
260
- )
261
- f.write(f"{alias_def}\n")
262
-
263
- print(f"✅ 快捷命令已添加到 {profile_file}")
264
- return True
265
-
266
- except Exception as e:
267
- print(f"❌ 创建快捷命令失败: {e}")
268
- return False
269
-
270
- def test_integration(self) -> bool:
271
- """测试集成是否正常工作"""
272
- try:
273
- # 测试CLI脚本
274
- result = subprocess.run(
275
- ["python", str(self.cli_script), "list"],
276
- capture_output=True,
277
- text=True,
278
- encoding='utf-8',
279
- timeout=10
280
- )
281
-
282
- if result.returncode != 0:
283
- print(f"❌ CLI脚本测试失败: {result.stderr}")
284
- return False
285
-
286
- # 测试Hook脚本
287
- result = subprocess.run(
288
- ["python", str(self.hook_script), "--list-intents"],
289
- capture_output=True,
290
- text=True,
291
- encoding='utf-8',
292
- timeout=10
293
- )
294
-
295
- if result.returncode != 0:
296
- print(f"❌ Hook脚本测试失败: {result.stderr}")
297
- return False
298
-
299
- print("✅ 集成测试通过")
300
- return True
301
-
302
- except Exception as e:
303
- print(f"❌ 集成测试失败: {e}")
304
- return False
305
-
306
- def uninstall_shell_integration(self, shell_type: str = None, global_command: str = "ai") -> bool:
307
- """卸载shell集成"""
308
- if shell_type is None:
309
- shell_type = self.detect_shell()
310
-
311
- if shell_type not in self.shell_configs:
312
- print(f"❌ 不支持的shell类型: {shell_type}")
313
- return False
314
-
315
- try:
316
- if shell_type in ['bash', 'zsh']:
317
- rc_file = Path(self.shell_configs[shell_type]["rc_file"]).expanduser()
318
- if rc_file.exists():
319
- content = rc_file.read_text(encoding='utf-8')
320
- lines = content.split('\n')
321
- new_lines = []
322
- skip = False
323
-
324
- for line in lines:
325
- if f"# iFlow CLI Integration" in line:
326
- skip = True
327
- elif skip and line.strip() and not line.startswith('#'):
328
- skip = False
329
- if not skip:
330
- new_lines.append(line)
331
-
332
- rc_file.write_text('\n'.join(new_lines), encoding='utf-8')
333
- print(f"✅ {shell_type} 集成已移除")
334
- return True
335
-
336
- elif shell_type == 'cmd':
337
- batch_file = Path(os.environ['USERPROFILE']) / f'{global_command}.bat'
338
- if batch_file.exists():
339
- batch_file.unlink()
340
- print("✅ CMD 集成已移除")
341
- return True
342
-
343
- except Exception as e:
344
- print(f"❌ 卸载失败: {e}")
345
- return False
346
-
347
- print(f"⚠️ 未找到 {shell_type} 集成")
348
- return False
349
-
350
-
351
- def main():
352
- """主函数"""
353
- import argparse
354
-
355
- parser = argparse.ArgumentParser(description="Shell集成工具")
356
- parser.add_argument("--install", action="store_true", help="安装shell集成")
357
- parser.add_argument("--uninstall", action="store_true", help="卸载shell集成")
358
- parser.add_argument("--test", action="store_true", help="测试集成")
359
- parser.add_argument("--shell", help="指定shell类型 (bash/zsh/fish/powershell/cmd)")
360
- parser.add_argument("--command", default="ai", help="全局命令名称")
361
- parser.add_argument("--shortcuts", help="创建快捷命令 (JSON格式)")
362
-
363
- args = parser.parse_args()
364
-
365
- integration = ShellIntegration()
366
-
367
- if args.install:
368
- integration.install_shell_integration(args.shell, args.command)
369
- if args.shortcuts:
370
- shortcuts = json.loads(args.shortcuts)
371
- integration.create_global_shortcuts(shortcuts)
372
-
373
- elif args.uninstall:
374
- integration.uninstall_shell_integration(args.shell, args.command)
375
-
376
- elif args.test:
377
- integration.test_integration()
378
-
379
- else:
380
- # 自动检测并安装
381
- shell_type = integration.detect_shell()
382
- print(f"🔍 检测到shell: {shell_type}")
383
-
384
- if integration.install_shell_integration(shell_type, args.command):
385
- # 创建常用快捷命令
386
- shortcuts = {
387
- "ai-chat": "gemini",
388
- "ai-code": "qodercli",
389
- "ai-local": "ollama",
390
- "ai-list": "list"
391
- }
392
- integration.create_global_shortcuts(shortcuts)
393
-
394
- integration.test_integration()
395
-
396
-
397
- if __name__ == "__main__":
398
- main()