multi-lang-build 0.3.0__py3-none-any.whl → 0.3.2__py3-none-any.whl

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.
@@ -7,7 +7,7 @@ from multi_lang_build.compiler.python import PythonCompiler
7
7
  from multi_lang_build.mirror.config import MirrorConfig, get_mirror_config
8
8
  from multi_lang_build.ide_register import register_skill
9
9
 
10
- __version__ = "0.3.0"
10
+ __version__ = "0.3.2"
11
11
  __all__ = [
12
12
  "BuildConfig",
13
13
  "BuildResult",
multi_lang_build/cli.py CHANGED
@@ -1,11 +1,11 @@
1
- """CLI interface for auto-build tool."""
1
+ """AutoBuild 工具的命令行接口。"""
2
2
 
3
3
  from pathlib import Path
4
4
  from typing import Sequence, TypedDict
5
5
 
6
6
 
7
7
  class BuildResult(TypedDict):
8
- """Result of a build operation."""
8
+ """构建操作的结果。"""
9
9
  success: bool
10
10
  return_code: int
11
11
  stdout: str
@@ -15,27 +15,27 @@ class BuildResult(TypedDict):
15
15
 
16
16
 
17
17
  def run_cli(args: Sequence[str]) -> None:
18
- """Run the CLI with the given arguments.
19
-
18
+ """使用给定的参数运行命令行接口。
19
+
20
20
  Args:
21
- args: Command line arguments (excluding program name)
21
+ args: 命令行参数(不包括程序名)
22
22
  """
23
23
  import argparse
24
24
  import sys
25
-
25
+
26
26
  parser = argparse.ArgumentParser(
27
- description="AutoBuild - Multi-language automated build tool",
27
+ description="AutoBuild - 多语言自动化构建工具",
28
28
  formatter_class=argparse.RawDescriptionHelpFormatter,
29
29
  epilog="""
30
- Examples:
30
+ 示例:
31
31
  %(prog)s pnpm ./src --output ./dist --mirror
32
32
  %(prog)s go ./src --output ./bin/app --mirror
33
33
  %(prog)s python ./src --output ./dist --mirror --poetry
34
34
 
35
- Supported languages:
36
- pnpm - Frontend JavaScript/TypeScript projects
37
- go - Go projects with module support
38
- python - Python projects with pip/poetry/pdm
35
+ 支持的语言:
36
+ pnpm - 前端 JavaScript/TypeScript 项目
37
+ go - Go 模块项目
38
+ python - Python pip/poetry/pdm 项目
39
39
  """,
40
40
  )
41
41
 
@@ -44,121 +44,121 @@ Supported languages:
44
44
  action="version",
45
45
  version=f"%(prog)s {__import__('multi_lang_build').__version__}",
46
46
  )
47
-
47
+
48
48
  subparsers = parser.add_subparsers(
49
49
  dest="language",
50
- title="language",
51
- description="Build tool for specific language",
50
+ title="语言",
51
+ description="特定语言的构建工具",
52
52
  )
53
53
 
54
54
  pnpm_parser = subparsers.add_parser(
55
55
  "pnpm",
56
- help="Build pnpm-based frontend projects",
57
- description="Build pnpm-based frontend projects with mirror acceleration",
56
+ help="构建基于 pnpm 的前端项目",
57
+ description="使用镜像加速构建基于 pnpm 的前端项目",
58
58
  )
59
- pnpm_parser.add_argument("source_dir", type=Path, help="Source directory")
60
- pnpm_parser.add_argument("-o", "--output", type=Path, required=True, help="Output directory")
61
- pnpm_parser.add_argument("--mirror/--no-mirror", default=True, help="Enable/disable mirror acceleration")
62
- pnpm_parser.add_argument("--script", type=str, help="Run specific npm script")
63
- pnpm_parser.add_argument("--install", action="store_true", help="Install dependencies only")
64
- pnpm_parser.add_argument("--stream/--no-stream", dest="stream_output", default=True, help="Enable/disable real-time output streaming (default: enabled)")
59
+ pnpm_parser.add_argument("source_dir", type=Path, help="源码目录")
60
+ pnpm_parser.add_argument("-o", "--output", type=Path, required=True, help="输出目录")
61
+ pnpm_parser.add_argument("--mirror/--no-mirror", default=True, help="启用/禁用镜像加速")
62
+ pnpm_parser.add_argument("--script", type=str, help="运行指定的 npm 脚本")
63
+ pnpm_parser.add_argument("--install", action="store_true", help="仅安装依赖")
64
+ pnpm_parser.add_argument("--stream/--no-stream", dest="stream_output", default=True, help="启用/禁用实时输出流(默认:启用)")
65
65
 
66
66
  go_parser = subparsers.add_parser(
67
67
  "go",
68
- help="Build Go projects",
69
- description="Build Go projects with module support and mirror acceleration",
68
+ help="构建 Go 项目",
69
+ description="使用模块支持和镜像加速构建 Go 项目",
70
70
  )
71
- go_parser.add_argument("source_dir", type=Path, help="Source directory")
72
- go_parser.add_argument("-o", "--output", type=Path, required=True, help="Output file or directory")
73
- go_parser.add_argument("--mirror", dest="mirror", action="store_true", default=True, help="Enable/disable Go proxy mirror")
74
- go_parser.add_argument("--no-mirror", dest="mirror", action="store_false", help="Enable/disable Go proxy mirror")
75
- go_parser.add_argument("--ldflags", type=str, help="Linker flags")
76
- go_parser.add_argument("--tags", type=str, help="Build tags (comma-separated)")
77
- go_parser.add_argument("--target", type=str, help="Build target package (e.g., ./cmd/server)")
78
- go_parser.add_argument("--test", action="store_true", help="Run tests instead of building")
79
- go_parser.add_argument("--tidy", action="store_true", help="Run go mod tidy")
80
- go_parser.add_argument("--all", action="store_true", help="Build all packages")
81
- go_parser.add_argument("--stream/--no-stream", dest="stream_output", default=True, help="Enable/disable real-time output streaming (default: enabled)")
71
+ go_parser.add_argument("source_dir", type=Path, help="源码目录")
72
+ go_parser.add_argument("-o", "--output", type=Path, required=True, help="输出文件或目录")
73
+ go_parser.add_argument("--mirror", dest="mirror", action="store_true", default=True, help="启用 Go 代理镜像")
74
+ go_parser.add_argument("--no-mirror", dest="mirror", action="store_false", help="禁用 Go 代理镜像")
75
+ go_parser.add_argument("--ldflags", type=str, help="链接器标志")
76
+ go_parser.add_argument("--tags", type=str, help="构建标签(逗号分隔)")
77
+ go_parser.add_argument("--target", type=str, help="构建目标包(例如:./cmd/server")
78
+ go_parser.add_argument("--test", action="store_true", help="运行测试而不是构建")
79
+ go_parser.add_argument("--tidy", action="store_true", help="运行 go mod tidy")
80
+ go_parser.add_argument("--all", action="store_true", help="构建所有包")
81
+ go_parser.add_argument("--stream/--no-stream", dest="stream_output", default=True, help="启用/禁用实时输出流(默认:启用)")
82
82
 
83
83
  python_parser = subparsers.add_parser(
84
84
  "python",
85
- help="Build Python projects",
86
- description="Build Python projects with pip/poetry/pdm and mirror acceleration",
85
+ help="构建 Python 项目",
86
+ description="使用 pip/poetry/pdm 和镜像加速构建 Python 项目",
87
87
  )
88
- python_parser.add_argument("source_dir", type=Path, help="Source directory")
89
- python_parser.add_argument("-o", "--output", type=Path, required=True, help="Output directory")
90
- python_parser.add_argument("--mirror/--no-mirror", default=True, help="Enable/disable PyPI mirror")
91
- python_parser.add_argument("--install", action="store_true", help="Install dependencies only")
92
- python_parser.add_argument("--dev", action="store_true", help="Include development dependencies")
93
- python_parser.add_argument("--poetry", action="store_true", help="Force using poetry")
94
- python_parser.add_argument("--create-venv", type=Path, help="Create virtual environment at path")
95
- python_parser.add_argument("--stream/--no-stream", dest="stream_output", default=True, help="Enable/disable real-time output streaming (default: enabled)")
88
+ python_parser.add_argument("source_dir", type=Path, help="源码目录")
89
+ python_parser.add_argument("-o", "--output", type=Path, required=True, help="输出目录")
90
+ python_parser.add_argument("--mirror/--no-mirror", default=True, help="启用/禁用 PyPI 镜像")
91
+ python_parser.add_argument("--install", action="store_true", help="仅安装依赖")
92
+ python_parser.add_argument("--dev", action="store_true", help="包含开发依赖")
93
+ python_parser.add_argument("--poetry", action="store_true", help="强制使用 poetry")
94
+ python_parser.add_argument("--create-venv", type=Path, help="在指定路径创建虚拟环境")
95
+ python_parser.add_argument("--stream/--no-stream", dest="stream_output", default=True, help="启用/禁用实时输出流(默认:启用)")
96
96
 
97
97
  mirror_parser = subparsers.add_parser(
98
98
  "mirror",
99
- help="Manage mirror configurations",
100
- description="List or configure domestic mirror acceleration settings",
99
+ help="管理镜像配置",
100
+ description="列出或配置国内镜像加速设置",
101
101
  epilog="""
102
- Examples:
103
- %(prog)s mirror list List all available mirrors
104
- %(prog)s mirror set pip Configure pip mirror (default)
105
- %(prog)s mirror set go Configure go proxy mirror
106
- %(prog)s mirror set pnpm Configure pnpm registry mirror
107
- %(prog)s mirror show Show current configuration
108
- %(prog)s mirror reset Reset configuration
102
+ 示例:
103
+ %(prog)s mirror list 列出所有可用镜像
104
+ %(prog)s mirror set pip 配置 pip 镜像(默认)
105
+ %(prog)s mirror set go 配置 go 代理镜像
106
+ %(prog)s mirror set pnpm 配置 pnpm 仓库镜像
107
+ %(prog)s mirror show 显示当前配置
108
+ %(prog)s mirror reset 重置配置
109
109
  """,
110
110
  )
111
111
  mirror_subparsers = mirror_parser.add_subparsers(dest="mirror_action")
112
112
 
113
- list_parser = mirror_subparsers.add_parser("list", help="List available mirrors")
114
- list_parser.add_argument("--json", action="store_true", help="Output as JSON")
113
+ list_parser = mirror_subparsers.add_parser("list", help="列出可用镜像")
114
+ list_parser.add_argument("--json", action="store_true", help=" JSON 格式输出")
115
115
 
116
- set_parser = mirror_subparsers.add_parser("set", help="Set mirror configuration")
116
+ set_parser = mirror_subparsers.add_parser("set", help="设置镜像配置")
117
117
  set_parser.add_argument(
118
118
  "type",
119
119
  type=str,
120
120
  default="pip",
121
121
  nargs="?",
122
122
  choices=["pip", "go", "npm", "pnpm"],
123
- help="Package manager type (default: pip)",
123
+ help="包管理器类型(默认:pip",
124
124
  )
125
125
  set_parser.add_argument(
126
126
  "mirror",
127
127
  type=str,
128
128
  nargs="?",
129
129
  default="pip",
130
- help="Mirror to use",
130
+ help="要使用的镜像",
131
131
  )
132
132
 
133
- show_parser = mirror_subparsers.add_parser("show", help="Show current configuration")
133
+ show_parser = mirror_subparsers.add_parser("show", help="显示当前配置")
134
134
  show_parser.add_argument(
135
135
  "--global",
136
136
  dest="global_level",
137
137
  action="store_true",
138
- help="Show global config instead of project-level",
138
+ help="显示全局配置而不是项目级配置",
139
139
  )
140
140
 
141
- reset_parser = mirror_subparsers.add_parser("reset", help="Reset configuration")
141
+ reset_parser = mirror_subparsers.add_parser("reset", help="重置配置")
142
142
  reset_parser.add_argument(
143
143
  "--global",
144
144
  dest="global_level",
145
145
  action="store_true",
146
- help="Reset global config instead of project-level",
146
+ help="重置全局配置而不是项目级配置",
147
147
  )
148
148
 
149
- # Register subcommand for IDE integration
149
+ # IDE 集成注册子命令
150
150
  register_parser = subparsers.add_parser(
151
151
  "register",
152
- help="Register as IDE skill (Claude Code, OpenCode, Trae, CodeBuddy)",
153
- description="Register multi-lang-build as a skill for various AI coding assistants and IDEs",
152
+ help="注册为 IDE 技能(Claude CodeOpenCodeTraeCodeBuddy",
153
+ description=" multi-lang-build 注册为各种 AI 编程助手和 IDE 的技能",
154
154
  epilog="""
155
- Examples:
156
- %(prog)s register # Register with Claude Code (default)
157
- %(prog)s register claude # Register with Claude Code
158
- %(prog)s register opencode # Register with OpenCode
159
- %(prog)s register trae # Register with Trae
160
- %(prog)s register codebuddy # Register with CodeBuddy
161
- %(prog)s register all # Register with all supported IDEs
155
+ 示例:
156
+ %(prog)s register # 注册到 Claude Code(默认)
157
+ %(prog)s register claude # 注册到 Claude Code
158
+ %(prog)s register opencode # 注册到 OpenCode
159
+ %(prog)s register trae # 注册到 Trae
160
+ %(prog)s register codebuddy # 注册到 CodeBuddy
161
+ %(prog)s register all # 注册到所有支持的 IDE
162
162
  """,
163
163
  )
164
164
  register_parser.add_argument(
@@ -166,7 +166,7 @@ Examples:
166
166
  nargs="?",
167
167
  default="claude",
168
168
  choices=["claude", "opencode", "trae", "codebuddy", "all"],
169
- help="IDE to register with (default: claude)",
169
+ help="要注册的 IDE(默认:claude",
170
170
  )
171
171
 
172
172
  parsed_args = parser.parse_args(args)
@@ -1,4 +1,4 @@
1
- """PNPM compiler with mirror acceleration support."""
1
+ """支持镜像加速的 PNPM 编译器。"""
2
2
 
3
3
  from pathlib import Path
4
4
  from typing import Final
@@ -11,16 +11,16 @@ from multi_lang_build.compiler.pnpm_support import PnpmProject, PnpmExecutor
11
11
 
12
12
 
13
13
  class PnpmCompiler(CompilerBase):
14
- """Compiler for pnpm-based frontend projects."""
14
+ """用于基于 pnpm 的前端项目的编译器。"""
15
15
 
16
16
  NAME: Final[str] = "pnpm"
17
17
  DEFAULT_MIRROR: Final[str] = "https://registry.npmmirror.com"
18
18
 
19
19
  def __init__(self, pnpm_path: str | None = None) -> None:
20
- """Initialize the PNPM compiler.
20
+ """初始化 PNPM 编译器。
21
21
 
22
22
  Args:
23
- pnpm_path: Optional path to pnpm executable. If None, uses system PATH.
23
+ pnpm_path: 可选的 pnpm 可执行文件路径。如果为 None,则使用系统 PATH
24
24
  """
25
25
  self._pnpm_path = pnpm_path
26
26
  self._version_cache: str | None = None
@@ -296,17 +296,17 @@ class PnpmCompiler(CompilerBase):
296
296
 
297
297
 
298
298
  def main() -> None:
299
- """PNPM compiler CLI entry point."""
299
+ """PNPM 编译器命令行入口点。"""
300
300
  import argparse
301
301
  import sys
302
302
 
303
- parser = argparse.ArgumentParser(description="PNPM Build Compiler")
304
- parser.add_argument("source_dir", type=Path, help="Source directory")
305
- parser.add_argument("-o", "--output", type=Path, required=True, help="Output directory")
306
- parser.add_argument("--mirror", action="store_true", default=True, help="Enable mirror acceleration")
307
- parser.add_argument("--no-mirror", dest="mirror", action="store_false", help="Disable mirror acceleration")
308
- parser.add_argument("--script", type=str, help="Run specific npm script instead of build")
309
- parser.add_argument("--install", action="store_true", help="Install dependencies only")
303
+ parser = argparse.ArgumentParser(description="PNPM 构建编译器")
304
+ parser.add_argument("source_dir", type=Path, help="源码目录")
305
+ parser.add_argument("-o", "--output", type=Path, required=True, help="输出目录")
306
+ parser.add_argument("--mirror", action="store_true", default=True, help="启用镜像加速")
307
+ parser.add_argument("--no-mirror", dest="mirror", action="store_false", help="禁用镜像加速")
308
+ parser.add_argument("--script", type=str, help="运行特定的 npm 脚本而不是构建")
309
+ parser.add_argument("--install", action="store_true", help="仅安装依赖")
310
310
 
311
311
  args = parser.parse_args()
312
312
 
@@ -1,22 +1,22 @@
1
- """Python compiler CLI entry point."""
1
+ """Python 编译器命令行入口。"""
2
2
 
3
3
  from pathlib import Path
4
4
 
5
5
 
6
6
  def main() -> None:
7
- """Python compiler CLI entry point."""
7
+ """Python 编译器命令行入口点。"""
8
8
  import argparse
9
9
  import sys
10
10
 
11
- parser = argparse.ArgumentParser(description="Python Build Compiler")
12
- parser.add_argument("source_dir", type=Path, help="Source directory")
13
- parser.add_argument("-o", "--output", type=Path, required=True, help="Output directory")
14
- parser.add_argument("--mirror", action="store_true", default=True, help="Enable PyPI mirror")
15
- parser.add_argument("--no-mirror", dest="mirror", action="store_false", help="Disable PyPI mirror")
16
- parser.add_argument("--install", action="store_true", help="Install dependencies only")
17
- parser.add_argument("--dev", action="store_true", help="Include dev dependencies")
18
- parser.add_argument("--poetry", action="store_true", help="Force using poetry")
19
- parser.add_argument("--create-venv", type=Path, help="Create virtual environment at path")
11
+ parser = argparse.ArgumentParser(description="Python 构建编译器")
12
+ parser.add_argument("source_dir", type=Path, help="源码目录")
13
+ parser.add_argument("-o", "--output", type=Path, required=True, help="输出目录")
14
+ parser.add_argument("--mirror", action="store_true", default=True, help="启用 PyPI 镜像")
15
+ parser.add_argument("--no-mirror", dest="mirror", action="store_false", help="禁用 PyPI 镜像")
16
+ parser.add_argument("--install", action="store_true", help="仅安装依赖")
17
+ parser.add_argument("--dev", action="store_true", help="包含开发依赖")
18
+ parser.add_argument("--poetry", action="store_true", help="强制使用 poetry")
19
+ parser.add_argument("--create-venv", type=Path, help="在指定路径创建虚拟环境")
20
20
 
21
21
  args = parser.parse_args()
22
22
 
@@ -0,0 +1,59 @@
1
+ """Structured logging configuration using loguru.
2
+
3
+ Configure the global loguru logger with structured output.
4
+ Other modules can simply: from loguru import logger
5
+
6
+ Usage:
7
+ from loguru import logger
8
+ logger.info('message', key1=value1, key2=value2)
9
+ """
10
+
11
+ import sys
12
+
13
+ from loguru import logger
14
+
15
+ # Remove default handler
16
+ logger.remove()
17
+
18
+ # Custom format function for structured logging
19
+ def _format(record: "loguru._logger.Record") -> str:
20
+ """Format log record with structured fields as key=value."""
21
+ # Get caller info
22
+ file_path = record["file"].name
23
+ short_file = file_path.split("/")[-1] if "/" in file_path else file_path
24
+ line = record["line"]
25
+ func = record["function"]
26
+
27
+ # Build message
28
+ message = record["message"]
29
+
30
+ # Format extra fields as key=value
31
+ extra = record.get("extra", {})
32
+ parts = []
33
+ for key, value in extra.items():
34
+ if isinstance(value, str) and (" " in value or "=" in value):
35
+ parts.append(f'{key}="{value}"')
36
+ elif value is None:
37
+ parts.append(f"{key}=null")
38
+ elif isinstance(value, bool):
39
+ parts.append(f"{key}={'true' if value else 'false'}")
40
+ else:
41
+ parts.append(f"{key}={value}")
42
+
43
+ fields_str = f" {' '.join(parts)}" if parts else ""
44
+
45
+ # Write directly to stdout to bypass loguru's colorizer
46
+ sys.stdout.write(f"[{short_file}:{line} {func}] {message}{fields_str}\n")
47
+ sys.stdout.flush()
48
+
49
+ # Return empty string to suppress loguru's own output
50
+ return ""
51
+
52
+
53
+ # Add configured handler with our custom format
54
+ logger.add(
55
+ sys.stdout,
56
+ format=_format,
57
+ level="INFO",
58
+ colorize=False,
59
+ )
@@ -1,4 +1,4 @@
1
- """Mirror configuration CLI for domestic acceleration."""
1
+ """国内镜像加速配置命令行工具。"""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -11,7 +11,7 @@ from typing import Literal
11
11
 
12
12
 
13
13
  def get_all_mirrors() -> dict:
14
- """Get all available mirrors with their configurations."""
14
+ """获取所有可用镜像及其配置。"""
15
15
  from multi_lang_build.mirror.config import MIRROR_CONFIGS
16
16
 
17
17
  mirrors = {}
@@ -24,13 +24,13 @@ def get_all_mirrors() -> dict:
24
24
 
25
25
 
26
26
  def print_mirrors() -> None:
27
- """Print all available mirrors."""
27
+ """打印所有可用镜像。"""
28
28
  mirrors = get_all_mirrors()
29
29
 
30
- print("\n📦 Available Mirrors:")
30
+ print("\n📦 可用镜像:")
31
31
  print("-" * 60)
32
32
 
33
- # Group by category
33
+ # 按类别分组
34
34
  categories = {
35
35
  "js": ["npm", "pnpm", "yarn"],
36
36
  "go": ["go", "go_qiniu", "go_vip"],
@@ -55,19 +55,19 @@ def print_mirrors() -> None:
55
55
 
56
56
 
57
57
  def configure_pip(mirror_key: str) -> bool:
58
- """Configure pip mirror using pip config command."""
58
+ """使用 pip config 命令配置 pip 镜像。"""
59
59
  from multi_lang_build.mirror.config import get_mirror_config
60
60
 
61
61
  config = get_mirror_config(mirror_key)
62
62
  if config is None:
63
- print(f"❌ Unknown pip mirror: {mirror_key}")
63
+ print(f"❌ 未知的 pip 镜像:{mirror_key}")
64
64
  return False
65
65
 
66
66
  url = config["url"]
67
67
  if not url.endswith("/simple") and not url.endswith("/simple/"):
68
68
  url = f"{url}/simple"
69
69
 
70
- # Try pip3 first, fallback to pip
70
+ # 优先使用 pip3,回退到 pip
71
71
  pip_cmd = "pip3" if sys.platform != "win32" else "pip"
72
72
 
73
73
  try:
@@ -75,36 +75,36 @@ def configure_pip(mirror_key: str) -> bool:
75
75
  [pip_cmd, "config", "set", "global.index-url", url],
76
76
  check=True,
77
77
  )
78
- print(f"✅ pip mirror set to: {url}")
78
+ print(f"✅ pip 镜像已设置为:{url}")
79
79
  return True
80
80
  except subprocess.CalledProcessError as e:
81
- print(f"❌ Failed to set pip mirror: {e}")
81
+ print(f"❌ 设置 pip 镜像失败:{e}")
82
82
  return False
83
83
  except FileNotFoundError:
84
- # Try alternative
84
+ # 尝试替代方案
85
85
  try:
86
86
  alternative = "pip" if pip_cmd == "pip3" else "pip3"
87
87
  subprocess.run(
88
88
  [alternative, "config", "set", "global.index-url", url],
89
89
  check=True,
90
90
  )
91
- print(f"✅ pip mirror set to: {url}")
91
+ print(f"✅ pip 镜像已设置为:{url}")
92
92
  return True
93
93
  except Exception:
94
- print("❌ pip/pip3 not found")
94
+ print("❌ 未找到 pip/pip3")
95
95
  return False
96
96
 
97
97
 
98
98
  def configure_go(mirror_key: str) -> bool:
99
- """Configure Go proxy using go env -w."""
99
+ """使用 go env -w 配置 Go 代理。"""
100
100
  from multi_lang_build.mirror.config import get_mirror_config
101
101
 
102
102
  config = get_mirror_config(mirror_key)
103
103
  if config is None:
104
- print(f"❌ Unknown Go mirror: {mirror_key}")
104
+ print(f"❌ 未知的 Go 镜像:{mirror_key}")
105
105
  return False
106
106
 
107
- # Get the GOPROXY value from environment variables
107
+ # 从环境变量中获取 GOPROXY
108
108
  proxy_value = config["environment_variables"].get("GOPROXY", f"{config['url']},direct")
109
109
 
110
110
  try:
@@ -112,33 +112,33 @@ def configure_go(mirror_key: str) -> bool:
112
112
  ["go", "env", "-w", f"GOPROXY={proxy_value}"],
113
113
  check=True,
114
114
  )
115
- print(f"✅ Go GOPROXY set to: {proxy_value}")
115
+ print(f"✅ Go GOPROXY 已设置为:{proxy_value}")
116
116
 
117
- # Also set GOSUMDB if present
117
+ # 如果存在也设置 GOSUMDB
118
118
  gosumdb = config["environment_variables"].get("GOSUMDB")
119
119
  if gosumdb:
120
120
  subprocess.run(
121
121
  ["go", "env", "-w", f"GOSUMDB={gosumdb}"],
122
122
  check=True,
123
123
  )
124
- print(f"✅ Go GOSUMDB set to: {gosumdb}")
124
+ print(f"✅ Go GOSUMDB 已设置为:{gosumdb}")
125
125
 
126
126
  return True
127
127
  except subprocess.CalledProcessError as e:
128
- print(f"❌ Failed to set Go mirror: {e}")
128
+ print(f"❌ 设置 Go 镜像失败:{e}")
129
129
  return False
130
130
  except FileNotFoundError:
131
- print("❌ go not found")
131
+ print("❌ 未找到 go")
132
132
  return False
133
133
 
134
134
 
135
135
  def configure_npm(mirror_key: str) -> bool:
136
- """Configure npm/pnpm registry."""
136
+ """配置 npm/pnpm 仓库。"""
137
137
  from multi_lang_build.mirror.config import get_mirror_config
138
138
 
139
139
  config = get_mirror_config(mirror_key)
140
140
  if config is None:
141
- print(f"❌ Unknown npm mirror: {mirror_key}")
141
+ print(f"❌ 未知的 npm 镜像:{mirror_key}")
142
142
  return False
143
143
 
144
144
  url = config["url"]
@@ -148,32 +148,32 @@ def configure_npm(mirror_key: str) -> bool:
148
148
  ["npm", "config", "set", "registry", url],
149
149
  check=True,
150
150
  )
151
- print(f"✅ npm registry set to: {url}")
151
+ print(f"✅ npm 仓库已设置为:{url}")
152
152
 
153
- # Also set for pnpm if available
153
+ # 如果可用也为 pnpm 设置
154
154
  try:
155
155
  subprocess.run(
156
156
  ["pnpm", "config", "set", "registry", url],
157
157
  check=True,
158
158
  )
159
- print(f"✅ pnpm registry set to: {url}")
159
+ print(f"✅ pnpm 仓库已设置为:{url}")
160
160
  except (subprocess.CalledProcessError, FileNotFoundError):
161
161
  pass
162
162
 
163
163
  return True
164
164
  except subprocess.CalledProcessError as e:
165
- print(f"❌ Failed to set npm registry: {e}")
165
+ print(f"❌ 设置 npm 仓库失败:{e}")
166
166
  return False
167
167
  except FileNotFoundError:
168
- print("❌ npm not found")
168
+ print("❌ 未找到 npm")
169
169
  return False
170
170
 
171
171
 
172
172
  def get_current_config() -> dict:
173
- """Get current mirror configuration."""
173
+ """获取当前镜像配置。"""
174
174
  config = {}
175
175
 
176
- # Try pip3 first, fallback to pip
176
+ # 优先使用 pip3,回退到 pip
177
177
  pip_cmd = "pip3" if sys.platform != "win32" else "pip"
178
178
 
179
179
  try:
@@ -187,7 +187,7 @@ def get_current_config() -> dict:
187
187
  except Exception:
188
188
  pass
189
189
 
190
- # Check Go
190
+ # 检查 Go
191
191
  try:
192
192
  result = subprocess.run(
193
193
  ["go", "env", "GOPROXY"],
@@ -199,7 +199,7 @@ def get_current_config() -> dict:
199
199
  except Exception:
200
200
  pass
201
201
 
202
- # Check npm
202
+ # 检查 npm
203
203
  try:
204
204
  result = subprocess.run(
205
205
  ["npm", "config", "get", "registry"],
@@ -215,14 +215,14 @@ def get_current_config() -> dict:
215
215
 
216
216
 
217
217
  def configure_mirror(mirror_type: str, mirror_key: str) -> bool:
218
- """Configure mirror for a specific package manager.
218
+ """为特定的包管理器配置镜像。
219
219
 
220
220
  Args:
221
- mirror_type: Package manager type (pip, go, npm)
222
- mirror_key: Mirror key to use
221
+ mirror_type: 包管理器类型(pipgonpm
222
+ mirror_key: 要使用的镜像键
223
223
 
224
224
  Returns:
225
- True if successful, False otherwise
225
+ 成功返回 True,失败返回 False
226
226
  """
227
227
  if mirror_type == "pip":
228
228
  return configure_pip(mirror_key)
@@ -231,67 +231,67 @@ def configure_mirror(mirror_type: str, mirror_key: str) -> bool:
231
231
  elif mirror_type in ["npm", "pnpm"]:
232
232
  return configure_npm(mirror_key)
233
233
  else:
234
- print(f"❌ Unknown package manager: {mirror_type}")
234
+ print(f"❌ 未知的包管理器:{mirror_type}")
235
235
  return False
236
236
 
237
237
 
238
238
  def mirror_main():
239
- """Main entry point for mirror command."""
239
+ """镜像命令的主入口点。"""
240
240
  import argparse
241
241
 
242
242
  parser = argparse.ArgumentParser(
243
- description="Configure domestic mirror acceleration",
243
+ description="配置国内镜像加速",
244
244
  epilog="""
245
- Examples:
246
- %(prog)s list List all available mirrors
247
- %(prog)s set pip Configure pip mirror (default)
248
- %(prog)s set go Configure Go proxy
249
- %(prog)s set npm Configure npm registry
250
- %(prog)s show Show current configuration
245
+ 示例:
246
+ %(prog)s list 列出所有可用镜像
247
+ %(prog)s set pip 配置 pip 镜像(默认)
248
+ %(prog)s set go 配置 Go 代理
249
+ %(prog)s set npm 配置 npm 仓库
250
+ %(prog)s show 显示当前配置
251
251
  """,
252
252
  )
253
253
  parser.add_argument(
254
254
  "--version",
255
255
  action="version",
256
- version="%(prog)s 0.2.2",
256
+ version="%(prog)s 0.3.2",
257
257
  )
258
258
 
259
- subparsers = parser.add_subparsers(dest="command", help="Commands")
259
+ subparsers = parser.add_subparsers(dest="command", help="命令")
260
260
 
261
- # list command
262
- list_parser = subparsers.add_parser("list", help="List available mirrors")
261
+ # list 命令
262
+ list_parser = subparsers.add_parser("list", help="列出可用镜像")
263
263
  list_parser.add_argument(
264
264
  "--json",
265
265
  action="store_true",
266
- help="Output as JSON",
266
+ help=" JSON 格式输出",
267
267
  )
268
268
  list_parser.add_argument(
269
269
  "--type",
270
270
  type=str,
271
271
  choices=["pip", "go", "npm"],
272
- help="Filter by type",
272
+ help="按类型筛选",
273
273
  )
274
274
 
275
- # set command
276
- set_parser = subparsers.add_parser("set", help="Configure mirror")
275
+ # set 命令
276
+ set_parser = subparsers.add_parser("set", help="配置镜像")
277
277
  set_parser.add_argument(
278
278
  "type",
279
279
  type=str,
280
280
  default="pip",
281
281
  nargs="?",
282
282
  choices=["pip", "go", "npm", "pnpm"],
283
- help="Package manager type (default: pip)",
283
+ help="包管理器类型(默认:pip",
284
284
  )
285
285
  set_parser.add_argument(
286
286
  "mirror",
287
287
  type=str,
288
288
  nargs="?",
289
289
  default="pip",
290
- help="Mirror to use",
290
+ help="要使用的镜像",
291
291
  )
292
292
 
293
- # show command
294
- show_parser = subparsers.add_parser("show", help="Show current mirror configuration")
293
+ # show 命令
294
+ show_parser = subparsers.add_parser("show", help="显示当前镜像配置")
295
295
 
296
296
  args = parser.parse_args()
297
297
 
@@ -311,25 +311,25 @@ Examples:
311
311
  elif args.command == "show":
312
312
  config = get_current_config()
313
313
  if config:
314
- print("\n📦 Current Mirror Configuration:")
314
+ print("\n📦 当前镜像配置:")
315
315
  print("-" * 40)
316
316
  for key, value in config.items():
317
317
  print(f" • {key}: {value}")
318
318
  print()
319
319
  else:
320
- print("\n📦 No mirror configured")
321
- print(" Run 'multi-lang-build mirror set <type> <mirror>' to configure")
320
+ print("\n📦 未配置镜像")
321
+ print(" 运行 'multi-lang-build mirror set <type> <mirror>' 进行配置")
322
322
  print()
323
323
  print_mirrors()
324
324
 
325
325
  else:
326
- # No subcommand, show help
326
+ # 无子命令,显示帮助
327
327
  parser.print_help()
328
- print("\n📋 Commands:")
329
- print(" list List all available mirrors")
330
- print(" set <type> <name> Configure mirror (type: pip/go/npm)")
331
- print(" show Show current configuration")
332
- print("\n📋 Examples:")
328
+ print("\n📋 命令:")
329
+ print(" list 列出所有可用镜像")
330
+ print(" set <type> <name> 配置镜像(类型:pip/go/npm")
331
+ print(" show 显示当前配置")
332
+ print("\n📋 示例:")
333
333
  print(" multi-lang-build mirror list")
334
334
  print(" multi-lang-build mirror set pip")
335
335
  print(" multi-lang-build mirror set go")
@@ -53,7 +53,7 @@ You can use the `multi-lang-build` tool to compile projects:
53
53
  multi-lang-build go ./src --output ./bin/app --mirror
54
54
 
55
55
  # Build with specific target (multi-entry support)
56
- multi-lang-build go ./src --output ./bin/server --target cmd/server/main.go
56
+ multi-lang-build go ./src --output ./bin/server --target ./cmd/server
57
57
 
58
58
  # Build Python project
59
59
  multi-lang-build python ./src --output ./dist --mirror
@@ -31,7 +31,7 @@ skills:
31
31
  multi-lang-build:
32
32
  name: "Multi-Lang Build"
33
33
  description: "Multi-language automated build tool with mirror acceleration"
34
- version: "0.2.0"
34
+ version: "0.3.0"
35
35
 
36
36
  commands:
37
37
  build-go:
@@ -45,7 +45,7 @@ def register_opencode(project_level: bool = True) -> bool:
45
45
  },
46
46
  "examples": [
47
47
  "multi-lang-build go ./src --output ./bin/app --mirror",
48
- "multi-lang-build go ./src --output ./bin/server --target cmd/server/main.go",
48
+ "multi-lang-build go ./src --output ./bin/server --target ./cmd/server",
49
49
  "multi-lang-build python ./src --output ./dist --mirror",
50
50
  "multi-lang-build pnpm ./src --output ./dist --mirror",
51
51
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: multi-lang-build
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Multi-language automated build tool with domestic mirror acceleration support
5
5
  Project-URL: Homepage, https://github.com/example/multi-lang-build
6
6
  Project-URL: Repository, https://github.com/example/multi-lang-build
@@ -177,35 +177,41 @@ compiler.build(
177
177
 
178
178
  | IDE | 命令 | 说明 |
179
179
  |-----|------|------|
180
- | 🤖 **Claude Code** | `multi-lang-build register` | 默认,AI 助手原生支持 |
181
- | 💠 **OpenCode** | `multi-lang-build register opencode` | 智能代码助手集成 |
182
- | 🔷 **Trae** | `multi-lang-build register trae` | 字节跳动 AI IDE |
183
- | 🎯 **CodeBuddy** | `multi-lang-build register codebuddy` | 代码伙伴插件 |
180
+ | 🤖 **Claude Code** | `multi-lang-register claude` | 默认,AI 助手原生支持 |
181
+ | 💠 **OpenCode** | `multi-lang-register opencode` | 智能代码助手集成 |
182
+ | 🔷 **Trae** | `multi-lang-register trae` | 字节跳动 AI IDE |
183
+ | 🎯 **CodeBuddy** | `multi-lang-register codebuddy` | 代码伙伴插件 |
184
184
 
185
185
  ### 注册 Claude Code(默认)
186
186
 
187
187
  ```bash
188
- # 默认注册到项目级(.claude/multi-lang-build.md)
189
- multi-lang-build register
188
+ # 使用独立命令
189
+ multi-lang-register
190
190
 
191
- # 或使用完整命令
192
- multi-lang-build register claude
191
+ # 或指定 IDE
192
+ multi-lang-register claude
193
+ multi-lang-register opencode
194
+ multi-lang-register trae
195
+ multi-lang-register codebuddy
193
196
 
194
197
  # 注册到全局配置
195
- multi-lang-build register claude --global
198
+ multi-lang-register claude --global
196
199
  ```
197
200
 
198
201
  ### 注册其他 IDE
199
202
 
200
203
  ```bash
201
204
  # 注册到 OpenCode
202
- multi-lang-build register opencode
205
+ multi-lang-register opencode
203
206
 
204
207
  # 注册到 Trae
205
- multi-lang-build register trae
208
+ multi-lang-register trae
206
209
 
207
210
  # 注册到 CodeBuddy
208
- multi-lang-build register codebuddy
211
+ multi-lang-register codebuddy
212
+
213
+ # 注册所有 IDE
214
+ multi-lang-register all
209
215
  ```
210
216
 
211
217
  ### 注册功能说明
@@ -214,10 +220,10 @@ multi-lang-build register codebuddy
214
220
 
215
221
  | IDE | 命令 | 项目级配置 | 全局配置 |
216
222
  |-----|------|-----------|---------|
217
- | 🤖 **Claude Code** | `multi-lang-build register` | `.claude/multi-lang-build.md` | `~/.claude/CLAUDE.md` |
218
- | 💠 **OpenCode** | `multi-lang-build register opencode` | `.opencode/skills.json` | `~/.config/opencode/skills.json` |
219
- | 🔷 **Trae** | `multi-lang-build register trae` | `.trae/skills.json` | `~/.trae/skills.json` |
220
- | 🎯 **CodeBuddy** | `multi-lang-build register codebuddy` | `.codebuddy/skills.yaml` | `~/.codebuddy/skills.yaml` |
223
+ | 🤖 **Claude Code** | `multi-lang-register claude` | `.claude/multi-lang-build.md` | `~/.claude/CLAUDE.md` |
224
+ | 💠 **OpenCode** | `multi-lang-register opencode` | `.opencode/skills.json` | `~/.config/opencode/skills.json` |
225
+ | 🔷 **Trae** | `multi-lang-register trae` | `.trae/skills.json` | `~/.trae/skills.json` |
226
+ | 🎯 **CodeBuddy** | `multi-lang-register codebuddy` | `.codebuddy/skills.yaml` | `~/.codebuddy/skills.yaml` |
221
227
 
222
228
  注册后,IDE 将自动识别项目类型并提供智能构建建议。
223
229
 
@@ -267,13 +273,12 @@ multi-lang-build python ./myproject --output ./dist --mirror
267
273
  # PNPM 项目构建
268
274
  multi-lang-build pnpm ./myproject --output ./dist --mirror
269
275
 
270
- # 注册到 IDE(默认 Claude Code)
271
- multi-lang-build register
272
-
273
- # 注册到指定 IDE
274
- multi-lang-build register opencode
275
- multi-lang-build register trae
276
- multi-lang-build register codebuddy
276
+ # 注册到 IDE(独立命令)
277
+ multi-lang-register # 默认 Claude Code
278
+ multi-lang-register opencode
279
+ multi-lang-register trae
280
+ multi-lang-register codebuddy
281
+ multi-lang-register all # 注册所有 IDE
277
282
 
278
283
  # 镜像配置
279
284
  multi-lang-build mirror list # 列出可用镜像
@@ -405,6 +410,13 @@ for pkg in ["ui", "utils", "app"]:
405
410
 
406
411
  ## 📋 更新日志
407
412
 
413
+ ### v0.3.1 (2026-02-03)
414
+
415
+ **🔧 重构**
416
+ - 使用 loguru 替换 ColorInfo 实现结构化日志
417
+ - 日志格式: `[file:line function] message key=value`
418
+ - 支持调用者位置追踪
419
+
408
420
  ### v0.3.0 (2026-02-03)
409
421
 
410
422
  **✨ 新功能**
@@ -1,12 +1,13 @@
1
- multi_lang_build/__init__.py,sha256=_3D4R7_1Y452wsSbtcqKetK3pUFVJvW3JWSH-CNZCFc,1794
2
- multi_lang_build/cli.py,sha256=v1xn2qfpj47n7rZQMg-Xiz8Tnu9aUEz--u9x4chH5vs,13246
1
+ multi_lang_build/__init__.py,sha256=Z-v3UAV2h5UcgPHTaD9nRNReyeQcOtFa5JCqa9ysyyg,1794
2
+ multi_lang_build/cli.py,sha256=6WBxezy39zSgBMsJEyx-QBJVFm5kB9kqh4hhxSnGhHw,12933
3
3
  multi_lang_build/ide_register.py,sha256=lz345IOs9S6-neh7t_6txJhz7XLypEiNzwvSl3ouVo8,3028
4
+ multi_lang_build/log.py,sha256=HM_0uGq8pGj_-9wR30iw1iGH1G0OvIJQb3x_AhKrRAE,1651
4
5
  multi_lang_build/py.typed,sha256=c8jtFarMovqA5DdwhEzKPH4WrX85xaoiWilIlvuc6KU,84
5
6
  multi_lang_build/types.py,sha256=iCyz_6KmEBU4xwpCtfJnpzXoiSsmOcOKOhzHJVx8Z4Q,1043
6
7
  multi_lang_build/compiler/__init__.py,sha256=7cfE3n7ATXZ8JabON_Qg0npxd7EY2jEU4tC6FxDupIs,493
7
8
  multi_lang_build/compiler/base.py,sha256=crtDW9bthfV-FSpp96O2Hi0DrViNqcIt4TjAVK2lPXE,9391
8
9
  multi_lang_build/compiler/go_compiler.py,sha256=3KrHEz8HtE0Gnck-8gtFMAIrUP5FOO15K7LqG0GyFCc,13830
9
- multi_lang_build/compiler/pnpm.py,sha256=0dwcf5LoPdzqlpkjEBVy8YNZNjd6CnUTOxIdonckwjo,10463
10
+ multi_lang_build/compiler/pnpm.py,sha256=JfmXeXJRgcWN9Jo_eclrGMACy6J6iInMrmUwVcMDA38,10450
10
11
  multi_lang_build/compiler/python.py,sha256=P-4ydqoUerMFkupVISu7j_KGSJVsZfmxeAZzCy36WWo,11797
11
12
  multi_lang_build/compiler/go_support/__init__.py,sha256=UGsWdG_RdbjgLGYtvbftjzLjPwHF9tmb-pmezKvEWMQ,675
12
13
  multi_lang_build/compiler/go_support/binary.py,sha256=bG452wvisoWlQDroBDNNXrR1SIHEMO1e0IQHsa-mF9I,3824
@@ -21,20 +22,20 @@ multi_lang_build/compiler/pnpm_support/executor.py,sha256=w52GN4fCGqbt90yEPq_Lya
21
22
  multi_lang_build/compiler/pnpm_support/project.py,sha256=JPHAxK0z1FOtNsAgJUUlp70wPGP4bq5pSB5o0FK44Co,1531
22
23
  multi_lang_build/compiler/python_support/__init__.py,sha256=YjLyDtSvFy9VnhD9f0Mr9saMk98FnsKOe5O1L5pOAVc,459
23
24
  multi_lang_build/compiler/python_support/cleaner.py,sha256=AT1KdRRX5vTGdtVLAgml2SuAUNEz0MzeuEgaHzBrAJo,1526
24
- multi_lang_build/compiler/python_support/cli.py,sha256=q3guZAST1Rs2gy79BOb9GAWvShy7LBcdl1R1p8nfNXY,1642
25
+ multi_lang_build/compiler/python_support/cli.py,sha256=dAmAX6XPbtmK8V24EzlUyTpJvR5BItjHyOj19mXkeWA,1625
25
26
  multi_lang_build/compiler/python_support/detector.py,sha256=eMHSLsU--a_LbyeXlgFuqwN_CHM8MeSbE8rNX8fe35E,1804
26
27
  multi_lang_build/compiler/python_support/installer.py,sha256=1gDqQPZRhYB6DIVlCxdRuIwJ_i5WpO4B5j2cG-VWVHI,4575
27
28
  multi_lang_build/compiler/python_support/venv.py,sha256=It6tppc7BFToJBzFxR9hPfpYeteVpNIw-mHjF3pwdr4,1957
28
29
  multi_lang_build/mirror/__init__.py,sha256=RrZOQ83bxImAR275zeAUKyyCgwqdGt5xH8tF_-UShJo,489
29
- multi_lang_build/mirror/cli.py,sha256=qv6RI6izxUIsfMCIDOtTK3avcNSJpAaUF3NPiK1W49A,9820
30
+ multi_lang_build/mirror/cli.py,sha256=pK3HaQZgoYfn5YbA0MpO_eJKLO63S3I67jtgZd3XSoQ,9759
30
31
  multi_lang_build/mirror/config.py,sha256=ZQo9upkE29vw0QFuBT6sYw85DhOhHQg59RSYu-OcdQg,9067
31
32
  multi_lang_build/register/support/__init__.py,sha256=Hg5oKJn5KhJ-qikzpDtFf0CO9WVnMvJVhExf20-PC10,443
32
- multi_lang_build/register/support/claude.py,sha256=YgXdU0--1wr6QIDL6rojY_zLKnlb-nu6fDqvpKywzd4,3370
33
- multi_lang_build/register/support/codebuddy.py,sha256=6ZPj0bs6erkSvok5lHueLbqxjIOCqml98zJoVTuBKj4,3356
34
- multi_lang_build/register/support/opencode.py,sha256=zGrTREyCNUX8RZgTbv9p2KV0ZcQjB68jZQqIClFbD1k,2394
33
+ multi_lang_build/register/support/claude.py,sha256=Ku4ZkVVEh6--ALlGKDG8brTWPKXpJsj0gp36pbqVFr8,3364
34
+ multi_lang_build/register/support/codebuddy.py,sha256=b0omRs2BcxeTdKho0aQ3bbjuzU6-WrcQFyCIuf-grQo,3356
35
+ multi_lang_build/register/support/opencode.py,sha256=B9x_cfJcWDjNLDiWZsN5Hj1TqlMGG9Zh0oeey8l16X8,2388
35
36
  multi_lang_build/register/support/trae.py,sha256=nkiQRCWp8in3cI3BLuWHMMLzQwiQQv3crxAU06sXOuk,2527
36
- multi_lang_build-0.3.0.dist-info/METADATA,sha256=9TkZPohwKmu_KV2vxzKjXJqMY2vfm-P7nkXi1chwrzQ,10882
37
- multi_lang_build-0.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
38
- multi_lang_build-0.3.0.dist-info/entry_points.txt,sha256=0vd5maQH5aZoqnpbr2Yr_IWB_-ncWX1rO3jGBCW3pHY,319
39
- multi_lang_build-0.3.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
40
- multi_lang_build-0.3.0.dist-info/RECORD,,
37
+ multi_lang_build-0.3.2.dist-info/METADATA,sha256=qfbbK4doSvfpEzkLVYCpcbRt1bZdKGaePSAHNw5Bw7Q,11122
38
+ multi_lang_build-0.3.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
39
+ multi_lang_build-0.3.2.dist-info/entry_points.txt,sha256=0vd5maQH5aZoqnpbr2Yr_IWB_-ncWX1rO3jGBCW3pHY,319
40
+ multi_lang_build-0.3.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
+ multi_lang_build-0.3.2.dist-info/RECORD,,