MintOS 0.1.1__tar.gz
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.
- mintos-0.1.1/PKG-INFO +58 -0
- mintos-0.1.1/README.md +34 -0
- mintos-0.1.1/pyproject.toml +42 -0
- mintos-0.1.1/setup.cfg +4 -0
- mintos-0.1.1/src/MintOS.egg-info/PKG-INFO +58 -0
- mintos-0.1.1/src/MintOS.egg-info/SOURCES.txt +34 -0
- mintos-0.1.1/src/MintOS.egg-info/dependency_links.txt +1 -0
- mintos-0.1.1/src/MintOS.egg-info/entry_points.txt +2 -0
- mintos-0.1.1/src/MintOS.egg-info/requires.txt +13 -0
- mintos-0.1.1/src/MintOS.egg-info/top_level.txt +1 -0
- mintos-0.1.1/src/mos/__init__.py +3 -0
- mintos-0.1.1/src/mos/cli/__init__.py +0 -0
- mintos-0.1.1/src/mos/cli/config.py +222 -0
- mintos-0.1.1/src/mos/cli/init.py +229 -0
- mintos-0.1.1/src/mos/cli/mcp.py +13 -0
- mintos-0.1.1/src/mos/cli/mos.py +43 -0
- mintos-0.1.1/src/mos/cli/plugin.py +125 -0
- mintos-0.1.1/src/mos/core/__init__.py +0 -0
- mintos-0.1.1/src/mos/core/baseconfig.py +196 -0
- mintos-0.1.1/src/mos/core/config.py +131 -0
- mintos-0.1.1/src/mos/core/dataflow/__init__.py +0 -0
- mintos-0.1.1/src/mos/core/dataflow/flat_json_model.py +141 -0
- mintos-0.1.1/src/mos/core/dataflow/types.py +126 -0
- mintos-0.1.1/src/mos/core/grafana/__init__.py +36 -0
- mintos-0.1.1/src/mos/core/grafana/manage.py +460 -0
- mintos-0.1.1/src/mos/core/influxdb/__init__.py +0 -0
- mintos-0.1.1/src/mos/core/influxdb/v3.py +0 -0
- mintos-0.1.1/src/mos/core/llm/__init__.py +0 -0
- mintos-0.1.1/src/mos/core/llm/openai_compatible_api.py +516 -0
- mintos-0.1.1/src/mos/core/logging.py +48 -0
- mintos-0.1.1/src/mos/core/mcp.py +4 -0
- mintos-0.1.1/src/mos/core/plugin.py +811 -0
- mintos-0.1.1/src/mos/core/resource.py +32 -0
- mintos-0.1.1/tests/test_core_config.py +461 -0
- mintos-0.1.1/tests/test_database.py +575 -0
- mintos-0.1.1/tests/test_llm_openai_compatible.py +302 -0
mintos-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: MintOS
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Mind OS or Money OS
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/tkorays/MOS
|
|
7
|
+
Project-URL: Issues, https://github.com/tkorays/MOS/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.13
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: python-dotenv>=1.2.1
|
|
13
|
+
Requires-Dist: loguru
|
|
14
|
+
Requires-Dist: pydantic-settings
|
|
15
|
+
Requires-Dist: pydantic
|
|
16
|
+
Requires-Dist: requests>=2.32.0
|
|
17
|
+
Requires-Dist: click>=8.4.1
|
|
18
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
19
|
+
Requires-Dist: mcp>=1.28.0
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff; extra == "dev"
|
|
24
|
+
|
|
25
|
+
# MOS
|
|
26
|
+
|
|
27
|
+
MOS 是一个基于 Python 的插件化框架,提供核心基础设施和插件管理能力。
|
|
28
|
+
|
|
29
|
+
## 核心特性
|
|
30
|
+
|
|
31
|
+
- **插件架构**:基于 Python entry_points 的标准插件机制
|
|
32
|
+
- **依赖隔离**:每个插件独立管理依赖,主仓库只包含核心框架
|
|
33
|
+
- **灵活安装**:插件可通过 pip 安装,支持从 Git、PyPI 或本地安装
|
|
34
|
+
|
|
35
|
+
## 可用插件
|
|
36
|
+
|
|
37
|
+
MOS 通过插件扩展功能,目前已有的插件:
|
|
38
|
+
|
|
39
|
+
| 插件 | 功能 | 安装方式 |
|
|
40
|
+
|------|------|----------|
|
|
41
|
+
| **mos-quant** | 量化交易框架,支持数据采集、回测、实盘交易 | `pip install mos-quant` |
|
|
42
|
+
| **mos-wiki** | 知识库管理系统,支持 Markdown 知识库管理 | `pip install mos-wiki` |
|
|
43
|
+
| **mos-agent** | 智能体系统,支持 LLM Agent 开发 | `pip install mos-agent` |
|
|
44
|
+
|
|
45
|
+
## 快速开始
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# 安装核心框架
|
|
49
|
+
pip install mos
|
|
50
|
+
|
|
51
|
+
# 安装插件(从 GitHub)
|
|
52
|
+
pip install git+https://github.com/yourname/mos_quant.git
|
|
53
|
+
pip install git+https://github.com/yourname/mos_wiki.git
|
|
54
|
+
pip install git+https://github.com/yourname/mos_agent.git
|
|
55
|
+
|
|
56
|
+
# 查看已加载插件
|
|
57
|
+
mos plugin list
|
|
58
|
+
```
|
mintos-0.1.1/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# MOS
|
|
2
|
+
|
|
3
|
+
MOS 是一个基于 Python 的插件化框架,提供核心基础设施和插件管理能力。
|
|
4
|
+
|
|
5
|
+
## 核心特性
|
|
6
|
+
|
|
7
|
+
- **插件架构**:基于 Python entry_points 的标准插件机制
|
|
8
|
+
- **依赖隔离**:每个插件独立管理依赖,主仓库只包含核心框架
|
|
9
|
+
- **灵活安装**:插件可通过 pip 安装,支持从 Git、PyPI 或本地安装
|
|
10
|
+
|
|
11
|
+
## 可用插件
|
|
12
|
+
|
|
13
|
+
MOS 通过插件扩展功能,目前已有的插件:
|
|
14
|
+
|
|
15
|
+
| 插件 | 功能 | 安装方式 |
|
|
16
|
+
|------|------|----------|
|
|
17
|
+
| **mos-quant** | 量化交易框架,支持数据采集、回测、实盘交易 | `pip install mos-quant` |
|
|
18
|
+
| **mos-wiki** | 知识库管理系统,支持 Markdown 知识库管理 | `pip install mos-wiki` |
|
|
19
|
+
| **mos-agent** | 智能体系统,支持 LLM Agent 开发 | `pip install mos-agent` |
|
|
20
|
+
|
|
21
|
+
## 快速开始
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 安装核心框架
|
|
25
|
+
pip install mos
|
|
26
|
+
|
|
27
|
+
# 安装插件(从 GitHub)
|
|
28
|
+
pip install git+https://github.com/yourname/mos_quant.git
|
|
29
|
+
pip install git+https://github.com/yourname/mos_wiki.git
|
|
30
|
+
pip install git+https://github.com/yourname/mos_agent.git
|
|
31
|
+
|
|
32
|
+
# 查看已加载插件
|
|
33
|
+
mos plugin list
|
|
34
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "MintOS"
|
|
3
|
+
version = "0.1.1"
|
|
4
|
+
description = "Mind OS or Money OS"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
dependencies = [
|
|
8
|
+
# Core framework dependencies
|
|
9
|
+
"python-dotenv>=1.2.1",
|
|
10
|
+
"loguru",
|
|
11
|
+
"pydantic-settings",
|
|
12
|
+
"pydantic",
|
|
13
|
+
"requests>=2.32.0",
|
|
14
|
+
"click>=8.4.1",
|
|
15
|
+
"pyyaml>=6.0.1",
|
|
16
|
+
"mcp>=1.28.0",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
]
|
|
22
|
+
license = "MIT"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
dev = [
|
|
27
|
+
"pytest>=8.0.0",
|
|
28
|
+
"pre-commit",
|
|
29
|
+
"ruff",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[build-system]
|
|
33
|
+
requires = ["setuptools>=61.0"]
|
|
34
|
+
build-backend = "setuptools.build_meta"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
[project.scripts]
|
|
38
|
+
mos = "mos.cli.mos:cli"
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/tkorays/MOS"
|
|
42
|
+
Issues = "https://github.com/tkorays/MOS/issues"
|
mintos-0.1.1/setup.cfg
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: MintOS
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Mind OS or Money OS
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/tkorays/MOS
|
|
7
|
+
Project-URL: Issues, https://github.com/tkorays/MOS/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.13
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: python-dotenv>=1.2.1
|
|
13
|
+
Requires-Dist: loguru
|
|
14
|
+
Requires-Dist: pydantic-settings
|
|
15
|
+
Requires-Dist: pydantic
|
|
16
|
+
Requires-Dist: requests>=2.32.0
|
|
17
|
+
Requires-Dist: click>=8.4.1
|
|
18
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
19
|
+
Requires-Dist: mcp>=1.28.0
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff; extra == "dev"
|
|
24
|
+
|
|
25
|
+
# MOS
|
|
26
|
+
|
|
27
|
+
MOS 是一个基于 Python 的插件化框架,提供核心基础设施和插件管理能力。
|
|
28
|
+
|
|
29
|
+
## 核心特性
|
|
30
|
+
|
|
31
|
+
- **插件架构**:基于 Python entry_points 的标准插件机制
|
|
32
|
+
- **依赖隔离**:每个插件独立管理依赖,主仓库只包含核心框架
|
|
33
|
+
- **灵活安装**:插件可通过 pip 安装,支持从 Git、PyPI 或本地安装
|
|
34
|
+
|
|
35
|
+
## 可用插件
|
|
36
|
+
|
|
37
|
+
MOS 通过插件扩展功能,目前已有的插件:
|
|
38
|
+
|
|
39
|
+
| 插件 | 功能 | 安装方式 |
|
|
40
|
+
|------|------|----------|
|
|
41
|
+
| **mos-quant** | 量化交易框架,支持数据采集、回测、实盘交易 | `pip install mos-quant` |
|
|
42
|
+
| **mos-wiki** | 知识库管理系统,支持 Markdown 知识库管理 | `pip install mos-wiki` |
|
|
43
|
+
| **mos-agent** | 智能体系统,支持 LLM Agent 开发 | `pip install mos-agent` |
|
|
44
|
+
|
|
45
|
+
## 快速开始
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# 安装核心框架
|
|
49
|
+
pip install mos
|
|
50
|
+
|
|
51
|
+
# 安装插件(从 GitHub)
|
|
52
|
+
pip install git+https://github.com/yourname/mos_quant.git
|
|
53
|
+
pip install git+https://github.com/yourname/mos_wiki.git
|
|
54
|
+
pip install git+https://github.com/yourname/mos_agent.git
|
|
55
|
+
|
|
56
|
+
# 查看已加载插件
|
|
57
|
+
mos plugin list
|
|
58
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/MintOS.egg-info/PKG-INFO
|
|
4
|
+
src/MintOS.egg-info/SOURCES.txt
|
|
5
|
+
src/MintOS.egg-info/dependency_links.txt
|
|
6
|
+
src/MintOS.egg-info/entry_points.txt
|
|
7
|
+
src/MintOS.egg-info/requires.txt
|
|
8
|
+
src/MintOS.egg-info/top_level.txt
|
|
9
|
+
src/mos/__init__.py
|
|
10
|
+
src/mos/cli/__init__.py
|
|
11
|
+
src/mos/cli/config.py
|
|
12
|
+
src/mos/cli/init.py
|
|
13
|
+
src/mos/cli/mcp.py
|
|
14
|
+
src/mos/cli/mos.py
|
|
15
|
+
src/mos/cli/plugin.py
|
|
16
|
+
src/mos/core/__init__.py
|
|
17
|
+
src/mos/core/baseconfig.py
|
|
18
|
+
src/mos/core/config.py
|
|
19
|
+
src/mos/core/logging.py
|
|
20
|
+
src/mos/core/mcp.py
|
|
21
|
+
src/mos/core/plugin.py
|
|
22
|
+
src/mos/core/resource.py
|
|
23
|
+
src/mos/core/dataflow/__init__.py
|
|
24
|
+
src/mos/core/dataflow/flat_json_model.py
|
|
25
|
+
src/mos/core/dataflow/types.py
|
|
26
|
+
src/mos/core/grafana/__init__.py
|
|
27
|
+
src/mos/core/grafana/manage.py
|
|
28
|
+
src/mos/core/influxdb/__init__.py
|
|
29
|
+
src/mos/core/influxdb/v3.py
|
|
30
|
+
src/mos/core/llm/__init__.py
|
|
31
|
+
src/mos/core/llm/openai_compatible_api.py
|
|
32
|
+
tests/test_core_config.py
|
|
33
|
+
tests/test_database.py
|
|
34
|
+
tests/test_llm_openai_compatible.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mos
|
|
File without changes
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from typing import Any, Callable
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
from pydantic import ValidationError
|
|
6
|
+
|
|
7
|
+
from mos.core.config import get_config, reload_config
|
|
8
|
+
from mos.core.plugin import get_registry
|
|
9
|
+
from mos.core.logging import get_logger
|
|
10
|
+
|
|
11
|
+
logger = get_logger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@click.group()
|
|
15
|
+
def config():
|
|
16
|
+
"""配置管理命令"""
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _get_config_funcs(config_type: str) -> tuple[Callable, Callable]:
|
|
21
|
+
"""根据配置类型获取对应的配置管理函数
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
config_type: 配置类型,'main' 表示主配置,其他为插件名称
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
(get_config_func, reload_config_func)
|
|
28
|
+
"""
|
|
29
|
+
if config_type == "main":
|
|
30
|
+
return get_config, reload_config
|
|
31
|
+
|
|
32
|
+
registry = get_registry()
|
|
33
|
+
get_func = registry.get_config_func(config_type)
|
|
34
|
+
reload_func = registry.get_reload_func(config_type)
|
|
35
|
+
|
|
36
|
+
if get_func is None or reload_func is None:
|
|
37
|
+
raise click.ClickException(f"未知的配置类型: '{config_type}'。可用类型: main, {', '.join(registry.list_names())}")
|
|
38
|
+
|
|
39
|
+
return get_func, reload_func
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _format_value(value):
|
|
43
|
+
"""格式化配置值为可读字符串"""
|
|
44
|
+
value_type = type(value)
|
|
45
|
+
|
|
46
|
+
if value_type is bool:
|
|
47
|
+
return "true" if value else "false"
|
|
48
|
+
elif value_type in (list, tuple):
|
|
49
|
+
return ", ".join(str(item) for item in value)
|
|
50
|
+
else:
|
|
51
|
+
return str(value)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _print_config_tree(data, prefix=""):
|
|
55
|
+
"""递归打印配置树"""
|
|
56
|
+
data_type = type(data)
|
|
57
|
+
|
|
58
|
+
if data_type is not dict:
|
|
59
|
+
click.echo(f"{prefix}{data}")
|
|
60
|
+
return
|
|
61
|
+
|
|
62
|
+
for key, value in data.items():
|
|
63
|
+
value_type = type(value)
|
|
64
|
+
|
|
65
|
+
if value is None:
|
|
66
|
+
click.echo(f"{prefix}{key}: null")
|
|
67
|
+
elif value_type is dict:
|
|
68
|
+
click.echo(f"{prefix}{key}:")
|
|
69
|
+
_print_config_tree(value, prefix + " ")
|
|
70
|
+
else:
|
|
71
|
+
display_value = _format_value(value)
|
|
72
|
+
click.echo(f"{prefix}{key}: {display_value}")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _coerce_cli_value(value: str) -> Any:
|
|
76
|
+
"""根据 CLI 字符串字面量推断 Python 标量(true/false/int/float/JSON/str)。"""
|
|
77
|
+
if value.startswith("~"):
|
|
78
|
+
return value
|
|
79
|
+
lowered = value.lower()
|
|
80
|
+
if lowered == "true":
|
|
81
|
+
return True
|
|
82
|
+
if lowered == "false":
|
|
83
|
+
return False
|
|
84
|
+
if value.isdigit():
|
|
85
|
+
return int(value)
|
|
86
|
+
try:
|
|
87
|
+
return float(value)
|
|
88
|
+
except ValueError:
|
|
89
|
+
if value.startswith("[") or value.startswith("{"):
|
|
90
|
+
return json.loads(value)
|
|
91
|
+
return value
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@click.command()
|
|
95
|
+
@click.option('--type', 'config_type', default='main', help='配置类型:main(主配置) 或插件名称(如 quant, wiki)')
|
|
96
|
+
def list(config_type: str):
|
|
97
|
+
"""列出所有配置项
|
|
98
|
+
|
|
99
|
+
示例:
|
|
100
|
+
mos config list # 列出主配置
|
|
101
|
+
mos config list --type quant # 列出 quant 插件配置
|
|
102
|
+
mos config list --type wiki # 列出 wiki 插件配置
|
|
103
|
+
"""
|
|
104
|
+
try:
|
|
105
|
+
get_config_func, _ = _get_config_funcs(config_type)
|
|
106
|
+
config_obj = get_config_func()
|
|
107
|
+
config_dict = config_obj.model_dump()
|
|
108
|
+
config_file = config_obj.config_file_path
|
|
109
|
+
|
|
110
|
+
click.echo(f"当前配置 ({config_type}):\n")
|
|
111
|
+
click.echo(f"配置文件: {config_file}")
|
|
112
|
+
click.echo(f"配置文件存在: {config_file.exists()}")
|
|
113
|
+
click.echo()
|
|
114
|
+
|
|
115
|
+
_print_config_tree(config_dict)
|
|
116
|
+
|
|
117
|
+
click.echo()
|
|
118
|
+
click.echo("提示: 使用 'mos config set <key> <value> --type <type>' 修改配置")
|
|
119
|
+
|
|
120
|
+
except Exception as e:
|
|
121
|
+
logger.error(f"列出配置失败: {e}")
|
|
122
|
+
raise click.ClickException(f"列出配置失败: {e}")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@click.command()
|
|
126
|
+
@click.argument("key")
|
|
127
|
+
@click.argument("value")
|
|
128
|
+
@click.option('--type', 'config_type', default='main', help='配置类型:main(主配置) 或插件名称(如 quant, wiki)')
|
|
129
|
+
def set(key, value, config_type: str):
|
|
130
|
+
"""设置配置项
|
|
131
|
+
|
|
132
|
+
示例:
|
|
133
|
+
mos config set log.level DEBUG
|
|
134
|
+
mos config set debug true --type main
|
|
135
|
+
mos config set database.path ~/.mos/custom_data/ --type quant
|
|
136
|
+
mos config set mini_qmt.path D:\\QMT --type quant
|
|
137
|
+
"""
|
|
138
|
+
try:
|
|
139
|
+
get_config_func, reload_config_func = _get_config_funcs(config_type)
|
|
140
|
+
keys = key.split(".")
|
|
141
|
+
if not keys or not all(keys):
|
|
142
|
+
raise click.ClickException(f"无效的 key: {key!r}")
|
|
143
|
+
|
|
144
|
+
# 用当前 Config 作为基线,把 CLI 改的字段 deep-merge 进去。
|
|
145
|
+
# pydantic 在 model_validate 阶段会做类型转换(str→int/bool/...)。
|
|
146
|
+
current = get_config_func()
|
|
147
|
+
override: dict[str, Any] = {}
|
|
148
|
+
cursor: dict[str, Any] = override
|
|
149
|
+
for k in keys[:-1]:
|
|
150
|
+
cursor[k] = {}
|
|
151
|
+
cursor = cursor[k]
|
|
152
|
+
cursor[keys[-1]] = _coerce_cli_value(value)
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
new_cfg = current.update(**override)
|
|
156
|
+
except ValidationError as e:
|
|
157
|
+
raise click.ClickException(f"配置项 {key!r} 校验失败: {e}")
|
|
158
|
+
|
|
159
|
+
target = new_cfg.save()
|
|
160
|
+
reload_config_func()
|
|
161
|
+
|
|
162
|
+
click.echo(f"[OK] 已设置 {config_type}.{key} = {value}")
|
|
163
|
+
click.echo(f" 配置文件: {target}")
|
|
164
|
+
click.echo()
|
|
165
|
+
click.echo("提示: 某些配置可能需要重启应用才能生效")
|
|
166
|
+
|
|
167
|
+
except click.ClickException:
|
|
168
|
+
raise
|
|
169
|
+
except Exception as e:
|
|
170
|
+
logger.error(f"设置配置失败: {e}")
|
|
171
|
+
raise click.ClickException(f"设置配置失败: {e}")
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
@click.command()
|
|
175
|
+
@click.argument("key")
|
|
176
|
+
@click.option('--type', 'config_type', default='main', help='配置类型:main(主配置) 或插件名称(如 quant, wiki)')
|
|
177
|
+
def get(key, config_type: str):
|
|
178
|
+
"""获取指定配置项的值
|
|
179
|
+
|
|
180
|
+
示例:
|
|
181
|
+
mos config get log.level
|
|
182
|
+
mos config get debug --type main
|
|
183
|
+
mos config get database.path --type quant
|
|
184
|
+
"""
|
|
185
|
+
try:
|
|
186
|
+
get_config_func, _ = _get_config_funcs(config_type)
|
|
187
|
+
config_obj = get_config_func()
|
|
188
|
+
value = config_obj.get(*key.split("."))
|
|
189
|
+
|
|
190
|
+
if value is None:
|
|
191
|
+
click.echo(f"配置项 '{config_type}.{key}' 不存在")
|
|
192
|
+
return
|
|
193
|
+
|
|
194
|
+
click.echo(f"{config_type}.{key} = {value}")
|
|
195
|
+
|
|
196
|
+
except Exception as e:
|
|
197
|
+
logger.error(f"获取配置失败: {e}")
|
|
198
|
+
raise click.ClickException(f"获取配置失败: {e}")
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@click.command()
|
|
202
|
+
@click.option('--type', 'config_type', default='main', help='配置类型:main(主配置) 或插件名称(如 quant, wiki)')
|
|
203
|
+
def types(config_type: str):
|
|
204
|
+
"""列出所有可用的配置类型"""
|
|
205
|
+
registry = get_registry()
|
|
206
|
+
plugin_names = registry.list_names()
|
|
207
|
+
|
|
208
|
+
click.echo("可用的配置类型:")
|
|
209
|
+
click.echo(" main - MOS 主配置 (log, llm, debug)")
|
|
210
|
+
for name in plugin_names:
|
|
211
|
+
click.echo(f" {name} - {name} 插件配置")
|
|
212
|
+
|
|
213
|
+
click.echo()
|
|
214
|
+
click.echo("示例:")
|
|
215
|
+
click.echo(" mos config list --type main")
|
|
216
|
+
click.echo(" mos config list --type quant")
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
config.add_command(list)
|
|
220
|
+
config.add_command(set)
|
|
221
|
+
config.add_command(get)
|
|
222
|
+
config.add_command(types)
|