From 5d081f87d1e42967bceab29f04052d36cf9c4a88 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Thu, 2 Apr 2026 20:37:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mise=20=E9=85=8D=E7=BD=AE=E5=BD=92?= =?UTF-8?q?=E5=B1=9E=20dev=20=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20AGENTS.md=20=E5=8C=B9=E9=85=8D=E5=BD=93=E5=89=8D=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 mise config.toml 从 base 移至 dev(包与配置同模块) - AGENTS.md 仓库结构图更新为 modules/ 目录 - 验证命令改为遍历 modules/*.py - 模块示例代码同步为当前写法 --- AGENTS.md | 25 +++++++++++++++---------- modules/base.py | 23 ++++++++++++++++++++++- modules/dev.py | 10 +++++++++- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index bc9b0cb..54de978 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,8 +13,13 @@ ``` . ├── source.py # decman 主配置入口 -├── locale_module.py # locale 模块(files + on_change hook) -├── docker_module.py # Docker 模块(packages + systemd units) +├── modules/ +│ ├── base.py # 基础模块(系统包 + 现代 CLI 工具 + 配置文件) +│ ├── dev.py # 开发模块(语言运行时 + 编辑器 + 工具链) +│ ├── docker.py # Docker 模块(packages + systemd units) +│ ├── locale.py # locale 模块(files + on_change hook) +│ ├── wsl.py # WSL 模块(WSL 特定适配) +│ └── zsh.py # Zsh 模块(shell + oh-my-zsh + 插件) ├── system/etc/ # 系统配置文件源 → 部署到 /etc/ ├── home/ # 用户配置文件源 → 部署到 ~/ ├── scripts/ @@ -46,10 +51,9 @@ sudo decman --debug ### 验证 ```bash -# Python 语法检查(所有 .py 文件) +# Python 语法检查(所有模块) python -c "import py_compile; py_compile.compile('source.py', doraise=True)" -python -c "import py_compile; py_compile.compile('docker_module.py', doraise=True)" -python -c "import py_compile; py_compile.compile('locale_module.py', doraise=True)" +for f in modules/*.py; do python -c "import py_compile; py_compile.compile('$f', doraise=True)"; done # Shell 语法检查 bash -n scripts/install.sh @@ -82,20 +86,21 @@ files → pacman → aur → systemd **模块模式**(适用于需要 hook 或跨步骤声明的场景): ```python from decman import Module -from decman.plugins.pacman import packages +from decman.plugins.pacman import packages as pacman_packages from decman.plugins.systemd import units class DockerModule(Module): - def __init__(self): + def __init__(self, user: str): super().__init__("docker") + self.user = user - @packages - def packages(self) -> set[str]: + @pacman_packages + def pacman_packages(self) -> set[str]: return {"docker", "docker-compose"} @units def units(self) -> set[str]: - return {"docker.service"} + return {"docker.socket"} ``` **何时用模块 vs 直接声明**: diff --git a/modules/base.py b/modules/base.py index 4fedc7a..f12df4b 100644 --- a/modules/base.py +++ b/modules/base.py @@ -4,8 +4,9 @@ from decman.plugins.pacman import packages as pacman_packages class BaseModule(Module): - def __init__(self): + def __init__(self, user: str): super().__init__("base") + self.user = user def files(self): return { @@ -16,6 +17,10 @@ class BaseModule(Module): source_file="./system/etc/sudoers.d/10-wheel", permissions=0o440, ), + f"/home/{self.user}/.config/git/config": File( + source_file="./home/.config/git/config", + owner=self.user, + ), } @pacman_packages @@ -23,11 +28,27 @@ class BaseModule(Module): return { "base-devel", "base", + "bat", + "btop", "curl", + "duf", + "dust", + "eza", + "fastfetch", + "fd", + "git-delta", "git", + "jq", + "micro", + "procs", + "ripgrep", "sudo", + "tealdeer", + "trash-cli", "vim", "wget", + "yazi", + "zoxide", } @aur_packages diff --git a/modules/dev.py b/modules/dev.py index dbb3d37..20c9a6e 100644 --- a/modules/dev.py +++ b/modules/dev.py @@ -1,5 +1,5 @@ import decman -from decman import Module +from decman import File, Module from decman.plugins.pacman import packages as pacman_packages BUN_GLOBAL_PACKAGES = [ @@ -17,6 +17,14 @@ class DevModule(Module): super().__init__("dev") self.user = user + def files(self): + return { + f"/home/{self.user}/.config/mise/config.toml": File( + source_file="./home/.config/mise/config.toml", + owner=self.user, + ), + } + @pacman_packages def pacman_packages(self) -> set[str]: return {