-
-
Notifications
You must be signed in to change notification settings - Fork 676
让CLI组织结构更整洁+来点颜色+子命令组功能增强! #1698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
文件级别更改
提示和命令与 Sourcery 互动
自定义您的体验访问您的 dashboard 以:
获取帮助
Original review guide in EnglishReviewer's GuideThis PR restructures the CLI package by centralizing command registration in the root module, modularizing Flow Diagram: Updated CLI Command Structuregraph TD
A[astrbot cli] --> help_cmd("help [command_name]")
A --> init_cmd("init")
A --> run_cmd("run [--reload] [--port]")
A --> conf_group("conf")
A --> plug_group("plug")
conf_group --> conf_set("set <key> <value>")
conf_group --> conf_get("get [key]")
plug_group --> plug_new("new <name>")
plug_group --> plug_list("list [--all]")
plug_group --> plug_install("install <name> [--proxy]")
plug_group --> plug_update("update [name] [--proxy]")
plug_group --> plug_remove("remove <name>")
plug_group --> plug_search("search <query>")
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @LIghtJUNction - 我已经审查了你的更改,并发现了一些需要解决的问题。
阻塞问题:
- 导入不存在的 CONFIG_VALIDATORS 将导致命令中断 (link)
一般评论:
astrbot.cli.plug.list
中的list
命令隐藏了内置的list
名称——考虑重命名它(例如list_plugins
)以避免混淆。- 在
conf/get.py
中,你从 utils 导入CONFIG_VALIDATORS
,但它只在conf/set.py
中定义——将该映射提取到一个共享模块中,以便 get 和 set 都可以一致地引用它。 - PR 在同一模块中混合了绝对导入和相对导入——选择一种样式(对于包内导入,首选相对导入)并始终如一地应用它,以提高可读性。
以下是我在审查期间查看的内容
- 🔴 一般问题:1 个阻塞问题,1 个其他问题
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟡 复杂性:发现 1 个问题
- 🟢 文档:一切看起来都很好
帮助我变得更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English
Hey @LIghtJUNction - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- Importing non-existent CONFIG_VALIDATORS will break command (link)
General comments:
- The
list
command inastrbot.cli.plug.list
shadows the built-inlist
name—consider renaming it (e.g.list_plugins
) to avoid confusion. - In
conf/get.py
you importCONFIG_VALIDATORS
from utils but it’s only defined inconf/set.py
—extract that mapping into a shared module so both get and set can reference it consistently. - The PR mixes absolute and relative imports within the same modules—pick one style (prefer relative for intra‐package imports) and apply it consistently to improve readability.
Here's what I looked at during the review
- 🔴 General issues: 1 blocking issue, 1 other issue
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
astrbot/cli/conf/set.py
Outdated
validate_callback_api_base, | ||
) | ||
# 可通过CLI设置的配置项,配置键到验证器函数的映射 | ||
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): 考虑将 CONFIG_VALIDATORS 移动到模块级别,并简化 set_config 函数,以提高效率和清晰度。
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { | |
# 将 CONFIG_VALIDATORS 移动到模块级别,这样它就不会在每次调用时重建 | |
# config/commands/set.py | |
from typing import Callable, Any | |
import click | |
from .utils import load_config, save_config | |
from ..utils import ( | |
validate_timezone, | |
validate_log_level, | |
validate_dashboard_port, | |
validate_dashboard_username, | |
validate_dashboard_password, | |
validate_callback_api_base, | |
) | |
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { | |
"timezone": validate_timezone, | |
"log_level": validate_log_level, | |
"dashboard.port": validate_dashboard_port, | |
"dashboard.username": validate_dashboard_username, | |
"dashboard.password": validate_dashboard_password, | |
"callback_api_base": validate_callback_api_base, | |
} | |
@click.command("set") | |
@click.argument("key") | |
@click.argument("value") | |
def set_config(key: str, value: str): | |
if key not in CONFIG_VALIDATORS: | |
raise click.ClickException(f"不支持的配置项: {key}") | |
# 1) 尽早且单独验证 | |
try: | |
validated = CONFIG_VALIDATORS[key](value) | |
except Exception as e: | |
raise click.UsageError(f"验证失败: {e}") | |
# 2) 加载和更新配置,使用简单的扁平/点状逻辑 | |
config = load_config() | |
parts = key.split(".", 1) | |
if len(parts) == 2: | |
section, field = parts | |
old = config.get(section, {}).get(field) | |
config.setdefault(section, {})[field] = validated | |
else: | |
old = config.get(key) | |
config[key] = validated | |
# 3) 保存并报告 | |
save_config(config) | |
click.echo(f"配置已更新: {key}") | |
if key == "dashboard.password": | |
click.echo(" 原值: ********") | |
click.echo(" 新值: ********") | |
else: | |
click.echo(f" 原值: {old}") | |
click.echo(f" 新值: {validated}") |
Original comment in English
issue (complexity): Consider moving CONFIG_VALIDATORS to the module level and simplifying the set_config function for better efficiency and clarity.
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { | |
# Move CONFIG_VALIDATORS to module‐level so it's not rebuilt on every call | |
# config/commands/set.py | |
from typing import Callable, Any | |
import click | |
from .utils import load_config, save_config | |
from ..utils import ( | |
validate_timezone, | |
validate_log_level, | |
validate_dashboard_port, | |
validate_dashboard_username, | |
validate_dashboard_password, | |
validate_callback_api_base, | |
) | |
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { | |
"timezone": validate_timezone, | |
"log_level": validate_log_level, | |
"dashboard.port": validate_dashboard_port, | |
"dashboard.username": validate_dashboard_username, | |
"dashboard.password": validate_dashboard_password, | |
"callback_api_base": validate_callback_api_base, | |
} | |
@click.command("set") | |
@click.argument("key") | |
@click.argument("value") | |
def set_config(key: str, value: str): | |
if key not in CONFIG_VALIDATORS: | |
raise click.ClickException(f"不支持的配置项: {key}") | |
# 1) Validate early and separately | |
try: | |
validated = CONFIG_VALIDATORS[key](value) | |
except Exception as e: | |
raise click.UsageError(f"验证失败: {e}") | |
# 2) Load and update config with simple flat/dotted logic | |
config = load_config() | |
parts = key.split(".", 1) | |
if len(parts) == 2: | |
section, field = parts | |
old = config.get(section, {}).get(field) | |
config.setdefault(section, {})[field] = validated | |
else: | |
old = config.get(key) | |
config[key] = validated | |
# 3) Save and report | |
save_config(config) | |
click.echo(f"配置已更新: {key}") | |
if key == "dashboard.password": | |
click.echo(" 原值: ********") | |
click.echo(" 新值: ********") | |
else: | |
click.echo(f" 原值: {old}") | |
click.echo(f" 新值: {validated}") |
astrbot/cli/conf/get.py
Outdated
try: | ||
value = get_nested_item(config, key) | ||
if key == "dashboard.password": | ||
value = "********" | ||
click.echo(f"{key}: {value}") | ||
except KeyError: | ||
raise click.ClickException(f"未知的配置项: {key}") | ||
except Exception as e: | ||
raise click.UsageError(f"获取配置失败: {str(e)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): 从先前的错误显式引发 [×2] (raise-from-previous-error
)
Original comment in English
issue (code-quality): Explicitly raise from a previous error [×2] (raise-from-previous-error
)
|
||
config = load_config() | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): 从先前的错误显式引发 [×2] (raise-from-previous-error
)
Original comment in English
issue (code-quality): Explicitly raise from a previous error [×2] (raise-from-previous-error
)
astrbot/cli/plug/remove.py
Outdated
shutil.rmtree(plugin_path) | ||
click.echo(f"插件 {name} 已卸载") | ||
except Exception as e: | ||
raise click.ClickException(f"卸载插件 {name} 失败: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): 显式地从先前的错误中引发 (raise-from-previous-error
)
raise click.ClickException(f"卸载插件 {name} 失败: {e}") | |
raise click.ClickException(f"卸载插件 {name} 失败: {e}") from e |
Original comment in English
suggestion (code-quality): Explicitly raise from a previous error (raise-from-previous-error
)
raise click.ClickException(f"卸载插件 {name} 失败: {e}") | |
raise click.ClickException(f"卸载插件 {name} 失败: {e}") from e |
astrbot/cli/plug/update.py
Outdated
plugin = next( | ||
( | ||
p | ||
for p in plugins | ||
if p["name"] == name and p["status"] == PluginStatus.NEED_UPDATE | ||
), | ||
None, | ||
) | ||
|
||
if not plugin: | ||
raise click.ClickException(f"插件 {name} 不需要更新或无法更新") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): 我们发现了这些问题:
- 使用命名表达式简化赋值和条件 (
use-named-expression
) - 在控制流跳转后将代码提升到 else 中 (
reintroduce-else
) - 交换 if/else 分支 (
swap-if-else-branches
)
Original comment in English
issue (code-quality): We've found these issues:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Lift code into else after jump in control flow (
reintroduce-else
) - Swap if/else branches (
swap-if-else-branches
)
if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]: | ||
raise click.ClickException( | ||
"日志级别必须是 DEBUG/INFO/WARNING/ERROR/CRITICAL 之一" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): 我们发现了这些问题:
- 在控制流跳转后将代码提升到 else 中 (
reintroduce-else
) - 交换 if/else 分支 (
swap-if-else-branches
) - 在检查字面量集合的成员资格时使用集合 (
collection-into-set
)
Original comment in English
issue (code-quality): We've found these issues:
- Lift code into else after jump in control flow (
reintroduce-else
) - Swap if/else branches (
swap-if-else-branches
) - Use set when checking membership of a collection of literals (
collection-into-set
)
except ValueError: | ||
raise click.ClickException("端口必须是数字") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): 显式地从先前的错误中引发 (raise-from-previous-error
)
except ValueError: | |
raise click.ClickException("端口必须是数字") | |
except ValueError as e: | |
raise click.ClickException("端口必须是数字") from e |
Original comment in English
suggestion (code-quality): Explicitly raise from a previous error (raise-from-previous-error
)
except ValueError: | |
raise click.ClickException("端口必须是数字") | |
except ValueError as e: | |
raise click.ClickException("端口必须是数字") from e |
修改完毕 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.不建议占用~/.astrbot
2.init不建议提供指定root目录的选项,仅允许初始化当前目录为root目录即可,比较符合直觉
3.部分插件及部分逻辑依赖data.plugins这一导入路径,所有插件命令建议统一指向<ASTRBOT_ROOT>/data/<folder>
astrbot/cli/conf/__main__.py
Outdated
@click.group(invoke_without_command=True) | ||
@click.option("--timezone","-tz", default="Asia/Shanghai", help="设置时区,默认 Asia/Shanghai") | ||
@click.option("--log-level", "-l", default="INFO", help="设置日志级别,默认 INFO") | ||
@click.option("--dashboard-port", "-dp", default=8080, help="设置仪表盘端口,默认 8080") | ||
@click.option("--dashboard-username", "-du", default="admin", help="设置仪表盘用户名,默认 admin") | ||
@click.option("--dashboard-password", "-dpw", default="admin", help="设置仪表盘密码,默认 admin") | ||
@click.option("--callback-api-base", "-cab", default="http://localhost:5000", help="设置回调 API 基础 URL,默认 http://localhost:5000") | ||
@click.pass_context | ||
def conf(ctx, timezone: str, log_level: str, dashboard_port: int, dashboard_username: str, dashboard_password: str, callback_api_base: str): | ||
"""配置管理子命令组""" | ||
if ctx.invoked_subcommand is None: | ||
# 检查是否有参数被设置为非默认值 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不建议占用过多选项
astrbot/cli/conf/set.py
Outdated
@click.option("--force", "-f", is_flag=True, help="强制设置,跳过验证器") | ||
@click.option("--create", "-c", is_flag=True, help="如果键不存在则创建") | ||
def set_config(key: str, value: str, type: str, force: bool, create: bool): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不建议提供强制设置的选项,当前无需提供--create flag
def validate_log_level(value: str) -> str: | ||
"""验证日志级别""" | ||
value = value.upper() | ||
if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里建议用集合
astrbot/cli/init.py
Outdated
import toml | ||
|
||
with open(dot_astrbot,"w") as f: | ||
toml.dump(metadata,f) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉没必要为了这个新增一个toml依赖,用yaml/json就可以
收到
________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:24 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
@Raven95676 requested changes on this pull request.
1.不建议占用~/.astrbot
2.init不建议提供指定root目录的选项,仅允许初始化当前目录为root目录即可,比较符合直觉
3.部分插件及部分逻辑依赖data.plugins这一导入路径,所有插件命令建议统一指向<ASTRBOT_ROOT>/data/
________________________________
In astrbot/cli/conf/__main__.py<#1698 (comment)>:
***@***.***(invoke_without_command=True)
***@***.***("--timezone","-tz", default="Asia/Shanghai", help="设置时区,默认 Asia/Shanghai")
***@***.***("--log-level", "-l", default="INFO", help="设置日志级别,默认 INFO")
***@***.***("--dashboard-port", "-dp", default=8080, help="设置仪表盘端口,默认 8080")
***@***.***("--dashboard-username", "-du", default="admin", help="设置仪表盘用户名,默认 admin")
***@***.***("--dashboard-password", "-dpw", default="admin", help="设置仪表盘密码,默认 admin")
***@***.***("--callback-api-base", "-cab", default="http://localhost:5000", help="设置回调 API 基础 URL,默认 http://localhost:5000")
***@***.***_context
+def conf(ctx, timezone: str, log_level: str, dashboard_port: int, dashboard_username: str, dashboard_password: str, callback_api_base: str):
+ """配置管理子命令组"""
+ if ctx.invoked_subcommand is None:
+ # 检查是否有参数被设置为非默认值
不建议占用过多选项
________________________________
In astrbot/cli/conf/set.py<#1698 (comment)>:
***@***.***("--force", "-f", is_flag=True, help="强制设置,跳过验证器")
***@***.***("--create", "-c", is_flag=True, help="如果键不存在则创建")
+def set_config(key: str, value: str, type: str, force: bool, create: bool):
不建议提供强制设置的选项,当前无需提供--create flag
________________________________
In astrbot/cli/utils/valutils.py<#1698 (comment)>:
@@ -0,0 +1,53 @@
+import hashlib
+import zoneinfo
+import click
+
+def validate_log_level(value: str) -> str:
+ """验证日志级别"""
+ value = value.upper()
+ if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
这里建议用集合
________________________________
In astrbot/cli/init.py<#1698 (comment)>:
+ import toml
+
+ with open(dot_astrbot,"w") as f:
+ toml.dump(metadata,f)
+
感觉没必要为了这个新增一个toml依赖,用yaml/json就可以
―
Reply to this email directly, view it on GitHub<#1698 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IOTAFRUBBNQSXT6XFD3CT467AVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSMBYHAYTOOJTHA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
我不想使用cwd主要是方便随处启动。避免到处初始化
________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:26 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
收到
________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:24 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
@Raven95676 requested changes on this pull request.
1.不建议占用~/.astrbot
2.init不建议提供指定root目录的选项,仅允许初始化当前目录为root目录即可,比较符合直觉
3.部分插件及部分逻辑依赖data.plugins这一导入路径,所有插件命令建议统一指向<ASTRBOT_ROOT>/data/
________________________________
In astrbot/cli/conf/__main__.py<#1698 (comment)>:
***@***.***(invoke_without_command=True)
***@***.***("--timezone","-tz", default="Asia/Shanghai", help="设置时区,默认 Asia/Shanghai")
***@***.***("--log-level", "-l", default="INFO", help="设置日志级别,默认 INFO")
***@***.***("--dashboard-port", "-dp", default=8080, help="设置仪表盘端口,默认 8080")
***@***.***("--dashboard-username", "-du", default="admin", help="设置仪表盘用户名,默认 admin")
***@***.***("--dashboard-password", "-dpw", default="admin", help="设置仪表盘密码,默认 admin")
***@***.***("--callback-api-base", "-cab", default="http://localhost:5000", help="设置回调 API 基础 URL,默认 http://localhost:5000")
***@***.***_context
+def conf(ctx, timezone: str, log_level: str, dashboard_port: int, dashboard_username: str, dashboard_password: str, callback_api_base: str):
+ """配置管理子命令组"""
+ if ctx.invoked_subcommand is None:
+ # 检查是否有参数被设置为非默认值
不建议占用过多选项
________________________________
In astrbot/cli/conf/set.py<#1698 (comment)>:
***@***.***("--force", "-f", is_flag=True, help="强制设置,跳过验证器")
***@***.***("--create", "-c", is_flag=True, help="如果键不存在则创建")
+def set_config(key: str, value: str, type: str, force: bool, create: bool):
不建议提供强制设置的选项,当前无需提供--create flag
________________________________
In astrbot/cli/utils/valutils.py<#1698 (comment)>:
@@ -0,0 +1,53 @@
+import hashlib
+import zoneinfo
+import click
+
+def validate_log_level(value: str) -> str:
+ """验证日志级别"""
+ value = value.upper()
+ if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
这里建议用集合
________________________________
In astrbot/cli/init.py<#1698 (comment)>:
+ import toml
+
+ with open(dot_astrbot,"w") as f:
+ toml.dump(metadata,f)
+
感觉没必要为了这个新增一个toml依赖,用yaml/json就可以
―
Reply to this email directly, view it on GitHub<#1698 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IOTAFRUBBNQSXT6XFD3CT467AVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSMBYHAYTOOJTHA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
个人感觉让用户在这里指定路径不如让用户cd过去( |
但是设置好环境变量就不用管了啊
________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:40 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
我不想使用cwd主要是方便随处启动。避免到处初始化
________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:26 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
收到
________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:24 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
@Raven95676 requested changes on this pull request.
1.不建议占用~/.astrbot
2.init不建议提供指定root目录的选项,仅允许初始化当前目录为root目录即可,比较符合直觉
3.部分插件及部分逻辑依赖data.plugins这一导入路径,所有插件命令建议统一指向<ASTRBOT_ROOT>/data/
________________________________
In astrbot/cli/conf/__main__.py<#1698 (comment)>:
***@***.***(invoke_without_command=True)
***@***.***("--timezone","-tz", default="Asia/Shanghai", help="设置时区,默认 Asia/Shanghai")
***@***.***("--log-level", "-l", default="INFO", help="设置日志级别,默认 INFO")
***@***.***("--dashboard-port", "-dp", default=8080, help="设置仪表盘端口,默认 8080")
***@***.***("--dashboard-username", "-du", default="admin", help="设置仪表盘用户名,默认 admin")
***@***.***("--dashboard-password", "-dpw", default="admin", help="设置仪表盘密码,默认 admin")
***@***.***("--callback-api-base", "-cab", default="http://localhost:5000", help="设置回调 API 基础 URL,默认 http://localhost:5000")
***@***.***_context
+def conf(ctx, timezone: str, log_level: str, dashboard_port: int, dashboard_username: str, dashboard_password: str, callback_api_base: str):
+ """配置管理子命令组"""
+ if ctx.invoked_subcommand is None:
+ # 检查是否有参数被设置为非默认值
不建议占用过多选项
________________________________
In astrbot/cli/conf/set.py<#1698 (comment)>:
***@***.***("--force", "-f", is_flag=True, help="强制设置,跳过验证器")
***@***.***("--create", "-c", is_flag=True, help="如果键不存在则创建")
+def set_config(key: str, value: str, type: str, force: bool, create: bool):
不建议提供强制设置的选项,当前无需提供--create flag
________________________________
In astrbot/cli/utils/valutils.py<#1698 (comment)>:
@@ -0,0 +1,53 @@
+import hashlib
+import zoneinfo
+import click
+
+def validate_log_level(value: str) -> str:
+ """验证日志级别"""
+ value = value.upper()
+ if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
这里建议用集合
________________________________
In astrbot/cli/init.py<#1698 (comment)>:
+ import toml
+
+ with open(dot_astrbot,"w") as f:
+ toml.dump(metadata,f)
+
感觉没必要为了这个新增一个toml依赖,用yaml/json就可以
―
Reply to this email directly, view it on GitHub<#1698 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IOTAFRUBBNQSXT6XFD3CT467AVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSMBYHAYTOOJTHA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
后面导入会很耗费时间的,启动CLI可能都会要接近1秒种。
现在启动就有一种很明显的顿挫感。解决办法最快捷的应该就是延迟导入了。
________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:47 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
但是设置好环境变量就不用管了啊
________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:40 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
我不想使用cwd主要是方便随处启动。避免到处初始化
________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:26 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
收到
________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:24 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
@Raven95676 requested changes on this pull request.
1.不建议占用~/.astrbot
2.init不建议提供指定root目录的选项,仅允许初始化当前目录为root目录即可,比较符合直觉
3.部分插件及部分逻辑依赖data.plugins这一导入路径,所有插件命令建议统一指向<ASTRBOT_ROOT>/data/
________________________________
In astrbot/cli/conf/__main__.py<#1698 (comment)>:
***@***.***(invoke_without_command=True)
***@***.***("--timezone","-tz", default="Asia/Shanghai", help="设置时区,默认 Asia/Shanghai")
***@***.***("--log-level", "-l", default="INFO", help="设置日志级别,默认 INFO")
***@***.***("--dashboard-port", "-dp", default=8080, help="设置仪表盘端口,默认 8080")
***@***.***("--dashboard-username", "-du", default="admin", help="设置仪表盘用户名,默认 admin")
***@***.***("--dashboard-password", "-dpw", default="admin", help="设置仪表盘密码,默认 admin")
***@***.***("--callback-api-base", "-cab", default="http://localhost:5000", help="设置回调 API 基础 URL,默认 http://localhost:5000")
***@***.***_context
+def conf(ctx, timezone: str, log_level: str, dashboard_port: int, dashboard_username: str, dashboard_password: str, callback_api_base: str):
+ """配置管理子命令组"""
+ if ctx.invoked_subcommand is None:
+ # 检查是否有参数被设置为非默认值
不建议占用过多选项
________________________________
In astrbot/cli/conf/set.py<#1698 (comment)>:
***@***.***("--force", "-f", is_flag=True, help="强制设置,跳过验证器")
***@***.***("--create", "-c", is_flag=True, help="如果键不存在则创建")
+def set_config(key: str, value: str, type: str, force: bool, create: bool):
不建议提供强制设置的选项,当前无需提供--create flag
________________________________
In astrbot/cli/utils/valutils.py<#1698 (comment)>:
@@ -0,0 +1,53 @@
+import hashlib
+import zoneinfo
+import click
+
+def validate_log_level(value: str) -> str:
+ """验证日志级别"""
+ value = value.upper()
+ if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
这里建议用集合
________________________________
In astrbot/cli/init.py<#1698 (comment)>:
+ import toml
+
+ with open(dot_astrbot,"w") as f:
+ toml.dump(metadata,f)
+
感觉没必要为了这个新增一个toml依赖,用yaml/json就可以
―
Reply to this email directly, view it on GitHub<#1698 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IOTAFRUBBNQSXT6XFD3CT467AVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSMBYHAYTOOJTHA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
我并没有反对延迟导入 |
我认同你的观点,按你的来改
…________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:51 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
[https://avatars.githubusercontent.com/u/176760093?s=20&v=4]Raven95676 left a comment (AstrBotDevs/AstrBot#1698)<#1698 (comment)>
后面导入会很耗费时间的,启动CLI可能都会要接近1秒种。 现在启动就有一种很明显的顿挫感。解决办法最快捷的应该就是延迟导入了。
我并没有反对延迟导入
―
Reply to this email directly, view it on GitHub<#1698 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IOCDVXBSZGCH2DPP4L3CUAFVAVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNJUGU2TQNRXGI>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
我只是顺嘴提一句,因为我自己写的CLI测试大概是700mm左右。现在我还在优化
…________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:52 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
我认同你的观点,按你的来改
________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:51 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
[https://avatars.githubusercontent.com/u/176760093?s=20&v=4]Raven95676 left a comment (AstrBotDevs/AstrBot#1698)<#1698 (comment)>
后面导入会很耗费时间的,启动CLI可能都会要接近1秒种。 现在启动就有一种很明显的顿挫感。解决办法最快捷的应该就是延迟导入了。
我并没有反对延迟导入
―
Reply to this email directly, view it on GitHub<#1698 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IOCDVXBSZGCH2DPP4L3CUAFVAVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNJUGU2TQNRXGI>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
从直觉上来说,init命令应该作用于当前目录而非其他目录 |
站在用户角度,用户使用uv tool install astrbot,并且每次打开系统终端时
默认就是在$HOME 也就是 ~/
那么用户大概率就是在~/初始化目录的,并不像我们开发者一样是源代码仓库内。
这就是为什么我不想设置为当前目录为根目录。
第二个原因就是,linux很多软件都是这个习惯,并不是我特意选这个目录,而是说这是一种习惯性的行为。
打开HOME目录,你可以看到很多软件都是类似的做法。
我个人觉得,~/.astrot可以仅存放一些元数据,大数据文件可以选择放到其他地方。
…________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:55 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
[https://avatars.githubusercontent.com/u/176760093?s=20&v=4]Raven95676 left a comment (AstrBotDevs/AstrBot#1698)<#1698 (comment)>
但是设置好环境变量就不用管了啊
@click.option("--root","-r",envvar="ASTRBOT_ROOT",required=True ,help="astrbot根目录,--root cwd表示使用当前目录",default=Path.home() / ".astrbot" )
从直觉上来说,init命令应该作用于当前目录而非其他目录
―
Reply to this email directly, view it on GitHub<#1698 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IJNFHIDXYM5ORK3LXD3CUATBAVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNJUGU3DEMRWGA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
已按要求更改
…________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 4:42 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
[https://avatars.githubusercontent.com/u/176760093?s=20&v=4]Raven95676 left a comment (AstrBotDevs/AstrBot#1698)<#1698 (comment)>
站在用户角度,用户使用uv tool install astrbot,并且每次打开系统终端时 默认就是在$HOME 也就是 / 那么用户大概率就是在/初始化目录的,并不像我们开发者一样是源代码仓库内。 这就是为什么我不想设置为当前目录为根目录。 第二个原因就是,linux很多软件都是这个习惯,并不是我特意选这个目录,而是说这是一种习惯性的行为。 打开HOME目录,你可以看到很多软件都是类似的做法。 我个人觉得,~/.astrot可以仅存放一些元数据,大数据文件可以选择放到其他地方。
image.png (view on web)<https://github.com/user-attachments/assets/5273c706-97fb-4c80-b4f0-51a4a3e98e4a>
―
Reply to this email directly, view it on GitHub<#1698 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IJJ5MEPZGIT4ECJHAD3CUGD3AVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNJUGYYTENJVGE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Enhanced the README files (Chinese, English, Japanese) with updated installation instructions, including uv-based and one-click install methods, and improved deployment documentation. Added new badges, updated community links, and expanded feature and update sections to reflect recent changes such as built-in knowledge base, MCP server support, and upcoming features. Reformatted tables and improved clarity and consistency across all language versions.
小更新 完善README.MD
本地同步上游更新,解决合并冲突问题 |
Bumped chardet to 5.2.0 and pydantic to 2.11.7 in pyproject.toml. Added a wildcard for '*.lock' files to .gitignore for broader lock file exclusion.
总结: 更新了README.MD |
解决了 #XYZ
Motivation
Modifications
规范性改动
并修复了一个导入错误,因为函数被弃用
Check
requirements.txt
和pyproject.toml
文件相应位置。好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
模块化并改进 AstrBot CLI,将命令重组为不同的模块,引入配置和插件管理组,修复导入问题,并增强验证和文档。
新特性:
Bug 修复:
增强:
文档:
Original summary in English
Summary by Sourcery
Modularize and refine the AstrBot CLI by reorganizing commands into distinct modules, introducing configuration and plugin management groups, fixing import issues, and enhancing validation and documentation.
New Features:
Bug Fixes:
Enhancements:
Documentation: