feat: 完成env重新设计

This commit is contained in:
2025-12-14 05:52:59 +08:00
parent e68eeb7e46
commit ca1a5836e1
23 changed files with 1316 additions and 743 deletions

View File

@@ -32,10 +32,22 @@ use_uv = true # 是否使用 uv 管理依赖
source = "task-now.md" # 任务原文档默认路径
spec = "task-spec.md" # 任务细则文档默认路径
# env: 虚拟环境与依赖配置
# env: 环境模块配置
[env]
venv = ".venv" # 虚拟环境路径
requirements = "requirements.txt" # 依赖文件路径
# 启用的模块列表
modules = ["python", "uv", "venv", "requirements"]
# Python 版本要求(可选,默认使用 runtime.python_min
# [env.python]
# min_version = "3.11"
# 虚拟环境配置类型B模块必须配置
[env.venv]
path = ".venv"
# 依赖文件配置类型B模块必须配置
[env.requirements]
path = "requirements.txt"
# flow: 流程配置
[flow]
@@ -67,18 +79,44 @@ phases = ["task-optimize", "flow-design", "impl", "verify", "docs", "finish"]
**使用场景**
- `/aide:prep` 未传参数时,使用 `source` 作为默认路径
- `/aide:exec` 未传参数时,使用 `spec` 作为默认路径
- `aide env ensure` 输出这两个路径供 LLM 记录
### 4.3 [env] 环境配置
#### 4.3.1 模块列表
| 字段 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| `venv` | string | `".venv"` | 虚拟环境目录路径 |
| `requirements` | string | `"requirements.txt"` | 依赖文件路径 |
| `modules` | array | `["python", "uv", "venv", "requirements"]` | 启用的环境检测模块 |
**可用模块**
- `python` - Python 解释器版本检测
- `uv` - uv 包管理器检测
- `venv` - Python 虚拟环境管理
- `requirements` - Python 依赖管理
#### 4.3.2 模块配置
**类型A模块可选配置**
```toml
[env.python]
min_version = "3.11" # Python 最低版本,默认使用 runtime.python_min
```
**类型B模块必须配置**
```toml
[env.venv]
path = ".venv" # 虚拟环境目录路径
[env.requirements]
path = "requirements.txt" # 依赖文件路径
```
**使用场景**
- `aide env ensure` 检查/创建虚拟环境
- `aide env ensure` 安装依赖
- `aide env ensure` `modules` 列表检测环境
- `aide env list` 显示所有可用模块及启用状态
- `aide env ensure --modules X,Y` 检测指定模块
### 4.4 [flow] 流程配置
@@ -105,8 +143,11 @@ aide config get <key>
aide config get task.source
# 输出: → task.source = 'task-now.md'
aide config get flow.phases
# 输出: → flow.phases = ['task-optimize', 'flow-design', 'impl', 'verify', 'docs', 'finish']
aide config get env.modules
# 输出: → env.modules = ['python', 'uv', 'venv', 'requirements']
aide config get env.venv.path
# 输出: → env.venv.path = '.venv'
aide config get runtime.python_min
# 输出: → runtime.python_min = '3.11'
@@ -123,8 +164,8 @@ aide config set <key> <value>
aide config set task.source "my-task.md"
# 输出: ✓ 已更新 task.source = 'my-task.md'
aide config set runtime.python_min "3.12"
# 输出: ✓ 已更新 runtime.python_min = '3.12'
aide config set env.venv.path ".venv-dev"
# 输出: ✓ 已更新 env.venv.path = '.venv-dev'
```
**值类型自动解析**
@@ -149,18 +190,63 @@ aide config set runtime.python_min "3.12"
- 配置项不存在时,`aide config get` 输出警告
- 建议先执行 `aide init` 确保配置文件存在
### 6.3 模块配置规则
- 类型A模块python, uv配置可选有默认行为
- 类型B模块venv, requirements如果在 `modules` 列表中启用,必须有对应配置
- 启用的B类模块无配置时`aide env ensure` 会报错
---
## 七、扩展配置
## 七、配置兼容性
### 7.1 添加新配置项
### 7.1 旧格式支持
aide 兼容旧版配置格式:
```toml
[env]
venv = ".venv"
requirements = "requirements.txt"
```
读取时自动转换为新格式:
```toml
[env.venv]
path = ".venv"
[env.requirements]
path = "requirements.txt"
```
### 7.2 默认模块列表
如果配置中没有 `env.modules` 字段,使用默认值:
```toml
modules = ["python", "uv", "venv", "requirements"]
```
---
## 八、扩展配置
### 8.1 添加新配置项
1. 在本文档添加字段说明
2. 更新 `ConfigManager` 中的 `DEFAULT_CONFIG`
3. 在相关代码中读取新配置
4. 更新相关设计文档
### 7.2 配置项命名规范
### 8.2 添加新环境模块
1.`aide/env/modules/` 创建模块文件
2.`registry.py` 注册模块
3. 更新本文档的模块列表
4. 更新 `aide env` 设计文档
### 8.3 配置项命名规范
- 使用小写字母和下划线
- 使用点号分隔层级:`section.key`
@@ -168,7 +254,7 @@ aide config set runtime.python_min "3.12"
---
## 、相关文档
## 、相关文档
- [program 导览](../README.md)
- [aide init 设计](../commands/init.md)