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,218 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AI CLI Router - 核心数据模型和类型定义
|
|
3
|
+
"""
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
from typing import Dict, List, Optional, Any
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
from enum import Enum
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CLIStatus(Enum):
|
|
11
|
+
"""CLI工具状态"""
|
|
12
|
+
AVAILABLE = "available"
|
|
13
|
+
UNAVAILABLE = "unavailable"
|
|
14
|
+
VERSION_INCOMPATIBLE = "version_incompatible"
|
|
15
|
+
CONFIG_MISSING = "config_missing"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class IntegrationType(Enum):
|
|
19
|
+
"""集成类型"""
|
|
20
|
+
HOOK_SYSTEM = "hook_system"
|
|
21
|
+
EXTENSION_SYSTEM = "extension_system"
|
|
22
|
+
CLASS_INHERITANCE = "class_inheritance"
|
|
23
|
+
WORKFLOW_PIPELINE = "workflow_pipeline"
|
|
24
|
+
NOTIFICATION_HOOK = "notification_hook"
|
|
25
|
+
MCP_SERVER = "mcp_server"
|
|
26
|
+
SLASH_COMMAND = "slash_command"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class CLIInfo:
|
|
31
|
+
"""CLI工具信息"""
|
|
32
|
+
name: str
|
|
33
|
+
display_name: str
|
|
34
|
+
version: str
|
|
35
|
+
integration_type: IntegrationType
|
|
36
|
+
status: CLIStatus
|
|
37
|
+
capabilities: List[str]
|
|
38
|
+
config_file: str
|
|
39
|
+
global_doc: str
|
|
40
|
+
protocols: List[str] = field(default_factory=list)
|
|
41
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@dataclass
|
|
45
|
+
class ProjectCLIInfo:
|
|
46
|
+
"""项目特定CLI信息"""
|
|
47
|
+
cli_name: str
|
|
48
|
+
project_config: Dict[str, Any]
|
|
49
|
+
custom_settings: Dict[str, Any] = field(default_factory=dict)
|
|
50
|
+
enabled_features: List[str] = field(default_factory=list)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@dataclass
|
|
54
|
+
class CollaborationGuide:
|
|
55
|
+
"""协作指南"""
|
|
56
|
+
current_cli: str
|
|
57
|
+
available_peers: Dict[str, CLIInfo]
|
|
58
|
+
protocols: Dict[str, List[str]]
|
|
59
|
+
examples: List[str] = field(default_factory=list)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class AIEnvironmentInfo:
|
|
64
|
+
"""AI环境信息"""
|
|
65
|
+
available_clis: Dict[str, CLIInfo]
|
|
66
|
+
project_specific_clis: Dict[str, ProjectCLIInfo]
|
|
67
|
+
collaboration_guide: CollaborationGuide
|
|
68
|
+
generated_at: datetime
|
|
69
|
+
scan_duration: Optional[float] = None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@dataclass
|
|
73
|
+
class ProjectStatus:
|
|
74
|
+
"""项目状态"""
|
|
75
|
+
is_existing_project: bool
|
|
76
|
+
existing_md_files: List[str]
|
|
77
|
+
total_expected: int
|
|
78
|
+
project_path: str
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dataclass
|
|
82
|
+
class EnhancementResult:
|
|
83
|
+
"""增强结果"""
|
|
84
|
+
enhanced: bool
|
|
85
|
+
added_collaboration_section: bool
|
|
86
|
+
original_sections: int
|
|
87
|
+
new_sections: int
|
|
88
|
+
enhancement_time: Optional[datetime] = None
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@dataclass
|
|
92
|
+
class GeneratedDocument:
|
|
93
|
+
"""生成的文档"""
|
|
94
|
+
file_path: str
|
|
95
|
+
sections_count: int
|
|
96
|
+
includes_collaboration: bool
|
|
97
|
+
generation_time: Optional[datetime] = None
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass
|
|
101
|
+
class InitResult:
|
|
102
|
+
"""初始化结果"""
|
|
103
|
+
project_type: str
|
|
104
|
+
ai_environment: AIEnvironmentInfo
|
|
105
|
+
message: str
|
|
106
|
+
enhanced_documents: Dict[str, EnhancementResult] = field(default_factory=dict)
|
|
107
|
+
generated_documents: Dict[str, GeneratedDocument] = field(default_factory=dict)
|
|
108
|
+
processing_time: Optional[float] = None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@dataclass
|
|
112
|
+
class MarkdownSection:
|
|
113
|
+
"""Markdown章节"""
|
|
114
|
+
title: str
|
|
115
|
+
content: List[str]
|
|
116
|
+
level: int
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class ProjectType(Enum):
|
|
120
|
+
"""项目类型"""
|
|
121
|
+
NEW_PROJECT = "new_project"
|
|
122
|
+
EXISTING_PROJECT = "existing_project"
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@dataclass
|
|
126
|
+
class CLIConfigMapping:
|
|
127
|
+
"""CLI配置映射"""
|
|
128
|
+
config_file: str
|
|
129
|
+
global_doc: str
|
|
130
|
+
integration_type: IntegrationType
|
|
131
|
+
adapter_class: Optional[str] = None
|
|
132
|
+
install_script: Optional[str] = None
|
|
133
|
+
version_check_command: Optional[str] = None
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# CLI工具配置映射表
|
|
137
|
+
CLI_CONFIG_MAPPING = {
|
|
138
|
+
"claude": CLIConfigMapping(
|
|
139
|
+
config_file="~/.config/claude/hooks.json",
|
|
140
|
+
global_doc="claude.md",
|
|
141
|
+
integration_type=IntegrationType.HOOK_SYSTEM,
|
|
142
|
+
install_script="install_claude_integration.py",
|
|
143
|
+
version_check_command="claude-cli --version"
|
|
144
|
+
),
|
|
145
|
+
"gemini": CLIConfigMapping(
|
|
146
|
+
config_file="~/.config/gemini/extensions.json",
|
|
147
|
+
global_doc="gemini.md",
|
|
148
|
+
integration_type=IntegrationType.EXTENSION_SYSTEM,
|
|
149
|
+
install_script="install_gemini_integration.py",
|
|
150
|
+
version_check_command="gemini-cli --version"
|
|
151
|
+
),
|
|
152
|
+
"qwen": CLIConfigMapping(
|
|
153
|
+
config_file="~/.config/qwencode/config.yml",
|
|
154
|
+
global_doc="qwen.md",
|
|
155
|
+
integration_type=IntegrationType.CLASS_INHERITANCE,
|
|
156
|
+
install_script="install_qwencode_integration.py",
|
|
157
|
+
version_check_command="qwencode-cli --version"
|
|
158
|
+
),
|
|
159
|
+
"iflow": CLIConfigMapping(
|
|
160
|
+
config_file="~/.config/iflow/hooks.yml",
|
|
161
|
+
global_doc="iflow.md",
|
|
162
|
+
integration_type=IntegrationType.WORKFLOW_PIPELINE,
|
|
163
|
+
install_script="install_iflow_integration.py",
|
|
164
|
+
version_check_command="iflow-cli --version"
|
|
165
|
+
),
|
|
166
|
+
"qoder": CLIConfigMapping(
|
|
167
|
+
config_file="~/.qoder/config.json",
|
|
168
|
+
global_doc="qoder.md",
|
|
169
|
+
integration_type=IntegrationType.NOTIFICATION_HOOK,
|
|
170
|
+
install_script="install_qoder_integration.py",
|
|
171
|
+
version_check_command="qoder-cli --version"
|
|
172
|
+
),
|
|
173
|
+
"codebuddy": CLIConfigMapping(
|
|
174
|
+
config_file="~/.codebuddy/buddy_config.json",
|
|
175
|
+
global_doc="codebuddy.md",
|
|
176
|
+
integration_type=IntegrationType.HOOK_SYSTEM,
|
|
177
|
+
install_script="install_codebuddy_integration.py",
|
|
178
|
+
version_check_command="codebuddy-cli --version"
|
|
179
|
+
),
|
|
180
|
+
"copilot": CLIConfigMapping(
|
|
181
|
+
config_file="~/.copilot/mcp-config.json",
|
|
182
|
+
global_doc="copilot.md",
|
|
183
|
+
integration_type=IntegrationType.MCP_SERVER,
|
|
184
|
+
install_script="install_copilot_integration.py",
|
|
185
|
+
version_check_command="copilot-cli --version"
|
|
186
|
+
),
|
|
187
|
+
"codex": CLIConfigMapping(
|
|
188
|
+
config_file="~/.config/codex/slash_commands.json",
|
|
189
|
+
global_doc="codex.md",
|
|
190
|
+
integration_type=IntegrationType.SLASH_COMMAND,
|
|
191
|
+
install_script="install_codex_integration.py",
|
|
192
|
+
version_check_command="codex-cli --version"
|
|
193
|
+
),
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
# 协作协议模板
|
|
197
|
+
COLLABORATION_PROTOCOLS = {
|
|
198
|
+
"chinese": [
|
|
199
|
+
"请用{cli}帮我{task}",
|
|
200
|
+
"调用{cli}来{task}",
|
|
201
|
+
"用{cli}帮我{task}",
|
|
202
|
+
"让{cli}帮我{task}",
|
|
203
|
+
"使用{cli}处理{task}",
|
|
204
|
+
"通过{cli}执行{task}",
|
|
205
|
+
"启动{cli}工作流{task}"
|
|
206
|
+
],
|
|
207
|
+
"english": [
|
|
208
|
+
"use {cli} to {task}",
|
|
209
|
+
"call {cli} to {task}",
|
|
210
|
+
"ask {cli} for {task}",
|
|
211
|
+
"tell {cli} to {task}",
|
|
212
|
+
"get {cli} to {task}",
|
|
213
|
+
"have {cli} {task}",
|
|
214
|
+
"start {cli} workflow for {task}",
|
|
215
|
+
"execute {task} with {cli}",
|
|
216
|
+
"process {task} using {cli}"
|
|
217
|
+
]
|
|
218
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""
|
|
2
|
+
自然语言解析器 - 核心版本
|
|
3
|
+
专注于检测跨CLI调用意图,无复杂抽象
|
|
4
|
+
"""
|
|
5
|
+
# -*- coding: utf-8 -*-
|
|
6
|
+
import re
|
|
7
|
+
import logging
|
|
8
|
+
from typing import Optional
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class IntentResult:
|
|
16
|
+
"""意图解析结果"""
|
|
17
|
+
is_cross_cli: bool = False
|
|
18
|
+
target_cli: Optional[str] = None
|
|
19
|
+
task: str = ""
|
|
20
|
+
confidence: float = 1.0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class NaturalLanguageParser:
|
|
24
|
+
"""简化的自然语言解析器"""
|
|
25
|
+
|
|
26
|
+
def __init__(self):
|
|
27
|
+
# 中英文跨CLI调用模式
|
|
28
|
+
self.cn_patterns = [
|
|
29
|
+
r'请用(\w+)\s*帮我?([^。!?\n]*)',
|
|
30
|
+
r'调用(\w+)\s*来([^。!?\n]*)',
|
|
31
|
+
r'用(\w+)\s*帮我?([^。!?\n]*)',
|
|
32
|
+
r'让(\w+)\s*帮我?([^。!?\n]*)',
|
|
33
|
+
r'使用(\w+)\s*处理([^。!?\n]*)',
|
|
34
|
+
r'通过(\w+)\s*执行([^。!?\n]*)'
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
self.en_patterns = [
|
|
38
|
+
r'use\s+(\w+)\s+to\s+([^.\n!?]*)',
|
|
39
|
+
r'call\s+(\w+)\s+to\s+([^.\n!?]*)',
|
|
40
|
+
r'ask\s+(\w+)\s+for\s+([^.\n!?]*)',
|
|
41
|
+
r'tell\s+(\w+)\s+to\s+([^.\n!?]*)',
|
|
42
|
+
r'get\s+(\w+)\s+to\s+([^.\n!?]*)',
|
|
43
|
+
r'have\s+(\w+)\s+([^.\n!?]*)',
|
|
44
|
+
r'execute\s+([^.\n!?]*)\s+with\s+(\w+)',
|
|
45
|
+
r'process\s+([^.\n!?]*)\s+using\s+(\w+)'
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
# 支持的CLI工具列表(用于验证)
|
|
49
|
+
self.supported_clis = [
|
|
50
|
+
'claude', 'gemini', 'qwen', 'iflow',
|
|
51
|
+
'qoder', 'codebuddy', 'copilot', 'codex'
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
def detect_cross_cli_call(self, text: str) -> bool:
|
|
55
|
+
"""检测是否为跨CLI调用"""
|
|
56
|
+
intent = self.parse_intent(text, "unknown")
|
|
57
|
+
return intent.is_cross_cli
|
|
58
|
+
|
|
59
|
+
def parse_intent(self, text: str, source_cli: str) -> IntentResult:
|
|
60
|
+
"""解析意图"""
|
|
61
|
+
text = text.strip()
|
|
62
|
+
|
|
63
|
+
# 检测中文模式
|
|
64
|
+
for pattern in self.cn_patterns:
|
|
65
|
+
match = re.search(pattern, text, re.IGNORECASE)
|
|
66
|
+
if match:
|
|
67
|
+
# 对于中文模式,CLI名称通常在第一组
|
|
68
|
+
cli_name = match.group(1).lower()
|
|
69
|
+
task = match.group(2).strip()
|
|
70
|
+
|
|
71
|
+
# 验证CLI名称是否受支持
|
|
72
|
+
if cli_name in self.supported_clis:
|
|
73
|
+
# 避免自我调用
|
|
74
|
+
if cli_name != source_cli.lower():
|
|
75
|
+
return IntentResult(
|
|
76
|
+
is_cross_cli=True,
|
|
77
|
+
target_cli=cli_name,
|
|
78
|
+
task=task,
|
|
79
|
+
confidence=0.9
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# 检测英文模式
|
|
83
|
+
for pattern in self.en_patterns:
|
|
84
|
+
match = re.search(pattern, text, re.IGNORECASE)
|
|
85
|
+
if match:
|
|
86
|
+
# 处理不同的英文模式
|
|
87
|
+
if len(match.groups()) >= 2:
|
|
88
|
+
# 标准模式:CLI名称在第一组
|
|
89
|
+
cli_name = match.group(1).lower()
|
|
90
|
+
task = match.group(2).strip()
|
|
91
|
+
else:
|
|
92
|
+
# 特殊模式:CLI名称在第二组
|
|
93
|
+
task = match.group(1).strip()
|
|
94
|
+
cli_name = match.group(2).lower() if len(match.groups()) > 1 else ""
|
|
95
|
+
|
|
96
|
+
# 验证CLI名称是否受支持
|
|
97
|
+
if cli_name in self.supported_clis:
|
|
98
|
+
# 避免自我调用
|
|
99
|
+
if cli_name != source_cli.lower():
|
|
100
|
+
return IntentResult(
|
|
101
|
+
is_cross_cli=True,
|
|
102
|
+
target_cli=cli_name,
|
|
103
|
+
task=task,
|
|
104
|
+
confidence=0.9
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
# 不是跨CLI调用
|
|
108
|
+
return IntentResult(is_cross_cli=False, task=text)
|