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 {