f4a82c9的任务收尾

This commit is contained in:
2025-12-18 18:18:43 +08:00
parent f4a82c96ee
commit b1c422ad7b
16 changed files with 301 additions and 244 deletions

View File

@@ -1,5 +1,5 @@
{
"next_number": 17,
"next_number": 18,
"branches": [
{
"number": 1,
@@ -186,6 +186,18 @@
"status": "finished",
"end_commit": "645a30cace5e7653c19c60fa1f23c22d1db73d34",
"finished_at": "2025-12-18T13:58:35+08:00"
},
{
"number": 17,
"branch_name": "aide/017",
"source_branch": "master",
"start_commit": "f4a82c96eec49822c39da4f68c87351fe527b0fe",
"task_id": "2025-12-18T14-09-44",
"task_summary": "开始任务准备: 调整aide收尾清理逻辑",
"started_at": "2025-12-18T14:09:44+08:00",
"status": "finished",
"end_commit": "f4a82c96eec49822c39da4f68c87351fe527b0fe",
"finished_at": "2025-12-18T18:18:43+08:00"
}
]
}

View File

@@ -1,5 +1,15 @@
# Git 分支概况
## aide/017
- **任务**: 开始任务准备: 调整aide收尾清理逻辑
- **任务ID**: 2025-12-18T14-09-44
- **源分支**: master
- **起始提交**: f4a82c9
- **结束提交**: f4a82c9
- **状态**: finished
- **时间**: 2025-12-18 14:09 ~ 18:18
## aide/016
- **任务**: 开始任务准备: 构建 auto-run 全自动任务执行命令

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

View File

@@ -1,73 +0,0 @@
@startuml auto-run-logic-flow
title auto-run 命令逻辑流图
|#LightBlue| 入口 |
start
:加载 aide skill;
:检查 flow 状态;
if (有活跃任务?) then (是)
:进入续接流程;
else (否)
:进入新任务流程;
endif
|#LightGreen| 新任务流程 |
:启动流程追踪;
:aide flow start task-optimize;
:读取任务文档;
:任务分析与优化;
if (有待定项?) then (是)
:分析各选项;
:自动选择 recommend 选项;
:记录决策理由;
else (否)
:继续;
endif
:生成任务细则;
note right: 无用户确认,直接继续
:aide flow next-part flow-design;
:创建流程图;
:aide flow next-part impl;
:迭代实现;
|#LightYellow| 错误处理 |
if (遇到错误?) then (是)
if (存在 general-purpose 子代理?) then (是)
:委托子代理解决;
else (否)
:记录遇到的情况;
:更新任务计划文档;
:自行解决问题;
endif
else (否)
:继续执行;
endif
|#LightGreen| 继续流程 |
:aide flow next-part verify;
:验证交付;
:aide flow next-part docs;
:文档更新;
note right
跳过 confirm 阶段
直接进入 finish
end note
:aide flow next-part finish;
:清理临时文件;
:汇报完成情况;
stop
@enduml

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -1,44 +0,0 @@
@startuml auto-run-task-flow
title auto-run 任务执行流程图
start
:复制 run.md 为 auto-run.md;
:修改命令标题和描述;
:改造待定项处理逻辑;
note right
- 移除用户 Web 决策
- 改为自动选择最优解
- 记录决策理由
end note
:删除任务细则确认;
note right
移除 AskUserQuestion 调用
end note
:删除 confirm 阶段;
note right
- 移除阶段 6 定义
- 调整流程跳转
- 移除返工流程
end note
:新增错误自动处理机制;
note right
优先委托子代理
否则自行解决
end note
:新增计划外情况处理机制;
note right
先记录 → 更新计划 → 再处理
end note
:验证命令文件;
stop
@enduml

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

View File

@@ -1,49 +0,0 @@
@startuml program-logic
title 程序逻辑流图finish_branch_merge 重构
start
:进入 finish_branch_merge();
note right: branch.py
:获取分支信息\nbranch_info = get_active_branch_info();
if (源分支有新提交?) then (是)
:创建临时分支合并\n(保持现有逻辑);
:返回提示信息;
stop
else (否)
:进入 _merge_normal();
endif
partition "清理操作" {
:删除 .aide/*.lock;
:删除 task-spec.md;
:清空 task-now.md\n(保留文件);
:备份并删除\nflow-status.json;
:备份并删除\ndecisions/*.json;
}
partition "创建临时提交" {
:git add -A;
:git commit\n"清理任务临时文件";
}
partition "切换并合并" {
:git checkout\n源分支;
:清理 .lock 文件;
:git merge --squash\n任务分支;
:构建提交信息\n格式: {hash}的任务收尾;
:git add -A;
:git commit\n收尾提交;
}
partition "更新记录" {
:更新分支记录\nstatus = finished;
:git add -A;
:git commit\n更新分支记录;
}
:返回成功;
stop
@enduml

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

View File

@@ -1,56 +0,0 @@
@startuml task-flow
!theme plain
title 任务执行流程图:调整 Aide 工作流流程
start
partition "1. 准备阶段" {
:读取 config.py;
:添加 plans_path 默认配置;
}
partition "2. run.md 修改 - 任务细则部分" {
:定位"1.8 生成任务细则"部分;
:增加复杂任务处理逻辑;
note right
- 判断是否为复杂任务
- 创建 .aide/task-plans/ 目录
- 生成 guide.md 总导览
- 生成 spec-NN.md 子计划
end note
}
partition "3. run.md 修改 - 子计划执行部分" {
:定位"复杂任务的子计划执行"部分;
:明确文档结构和操作方式;
}
partition "4. run.md 修改 - 插入 confirm 阶段" {
:定位"阶段 5文档更新"之后;
:插入"阶段 6用户确认 (confirm)";
note right
- 报告完成信息
- 等待用户确认
- 返工机制说明
end note
:将原"阶段 6收尾"改为"阶段 7收尾";
}
partition "5. aide skill 更新" {
:读取 aide.md;
:添加 plans_path 配置说明;
:更新环节列表(增加 confirm;
}
partition "6. 验证" {
:检查所有修改点;
if (验证通过?) then (是)
:完成;
else (否)
:修复问题;
endif
}
stop
@enduml

View File

@@ -0,0 +1,155 @@
{
"task_id": "2025-12-18T14-09-44",
"current_phase": "finish",
"current_step": 18,
"started_at": "2025-12-18T14:09:44+08:00",
"history": [
{
"timestamp": "2025-12-18T14:09:44+08:00",
"action": "start",
"phase": "task-optimize",
"step": 1,
"summary": "开始任务准备: 调整aide收尾清理逻辑",
"git_commit": "58e6d2860c4aab56501416242b4ac635c2afa760"
},
{
"timestamp": "2025-12-18T14:13:19+08:00",
"action": "next-step",
"phase": "task-optimize",
"step": 2,
"summary": "任务分析完成,无待定项",
"git_commit": "748796325dbb94b666aea08439c009c30fa68aa4"
},
{
"timestamp": "2025-12-18T14:14:15+08:00",
"action": "next-step",
"phase": "task-optimize",
"step": 3,
"summary": "任务细则已生成,自动确认",
"git_commit": "cf57481bcff2d8e57ba8d3c2c66a7120d53e5221"
},
{
"timestamp": "2025-12-18T14:14:27+08:00",
"action": "next-part",
"phase": "flow-design",
"step": 4,
"summary": "进入流程设计环节",
"git_commit": "5369765724248c11e21c2a58184db149473c83c4"
},
{
"timestamp": "2025-12-18T14:15:01+08:00",
"action": "next-step",
"phase": "flow-design",
"step": 5,
"summary": "流程图设计完成",
"git_commit": "55904d9416a13df115dac01be763cfc626e1b837"
},
{
"timestamp": "2025-12-18T14:15:26+08:00",
"action": "next-part",
"phase": "impl",
"step": 6,
"summary": "流程设计完成,进入实现环节",
"git_commit": "3e7f1ab05855d18d344cee32c96a27ccd049bdd3"
},
{
"timestamp": "2025-12-18T14:16:16+08:00",
"action": "next-step",
"phase": "impl",
"step": 7,
"summary": "完成代码修改:添加 pending-items.json 和流程图文件清理逻辑",
"git_commit": "6f44b388c8e3cf1e25dd2465d80e474dcdc19fdd"
},
{
"timestamp": "2025-12-18T14:17:04+08:00",
"action": "next-part",
"phase": "verify",
"step": 8,
"summary": "实现完成,进入验证环节",
"git_commit": "e0823e096c4051a43695cae2214d2bb472fc955b"
},
{
"timestamp": "2025-12-18T14:26:30+08:00",
"action": "back-part",
"phase": "task-optimize",
"step": 9,
"summary": "返工:添加 aide 命令递归查找 .aide 目录的需求",
"git_commit": "1d2de3efe04fe1679c013c47c7995bf41fe19d68"
},
{
"timestamp": "2025-12-18T14:50:27+08:00",
"action": "next-step",
"phase": "task-optimize",
"step": 10,
"summary": "完成代码实现:收尾清理增强 + 递归查找功能",
"git_commit": "82633b90fd0cb423f870283cf41179d4bb62b574"
},
{
"timestamp": "2025-12-18T18:13:11+08:00",
"action": "next-part",
"phase": "flow-design",
"step": 11,
"summary": "进入流程设计环节",
"git_commit": "19d2e727542b3ab1320c956373064c8a272868be"
},
{
"timestamp": "2025-12-18T18:13:31+08:00",
"action": "next-part",
"phase": "impl",
"step": 12,
"summary": "流程设计已有,进入实现环节",
"git_commit": "ba8f4a9a6ce8a1f803a83febc1f02320525f11b7"
},
{
"timestamp": "2025-12-18T18:13:42+08:00",
"action": "next-part",
"phase": "verify",
"step": 13,
"summary": "实现完成,进入验证环节",
"git_commit": "47e21e2b2617573a3cd7adf8fca2d26dae3f19c6"
},
{
"timestamp": "2025-12-18T18:14:24+08:00",
"action": "next-part",
"phase": "docs",
"step": 14,
"summary": "验证通过,进入文档更新环节",
"git_commit": "beeb93e782498e9c1521bf34d93c85f81038b9d0"
},
{
"timestamp": "2025-12-18T18:16:40+08:00",
"action": "next-step",
"phase": "docs",
"step": 15,
"summary": "CHANGELOG.md 已在之前更新完成",
"git_commit": "e3b5e45d329f3a0c8ee06c6d88858d32a01d6de9"
},
{
"timestamp": "2025-12-18T18:17:59+08:00",
"action": "next-step",
"phase": "docs",
"step": 16,
"summary": "完善 CHANGELOG.md 格式",
"git_commit": "5ee698c22064fd0ef86c070a365aa6000c1273a3"
},
{
"timestamp": "2025-12-18T18:18:13+08:00",
"action": "next-part",
"phase": "confirm",
"step": 17,
"summary": "文档更新完成,进入确认环节",
"git_commit": "8f93eb8c40199206740f31b48737512fb59026bf"
},
{
"timestamp": "2025-12-18T18:18:43+08:00",
"action": "next-part",
"phase": "finish",
"step": 18,
"summary": "确认完成,进入收尾环节",
"git_commit": "8fb54dca415446b11643961a2c552f3fc59c8e10"
}
],
"source_branch": "master",
"start_commit": "f4a82c96eec49822c39da4f68c87351fe527b0fe",
"task_branch": "aide/017"
}

View File

@@ -4,6 +4,33 @@
## 2025-12-18
### 改进
**收尾清理逻辑增强**
- 新增删除 `pending-items.json` 文件的清理步骤
- 新增删除流程图目录(`.aide/diagrams/`)下所有文件的清理步骤
- 支持删除 `.puml``.plantuml``.png` 文件
- 保留目录本身
### 修改的文件
- `aide-program/aide/flow/branch.py` - `_cleanup_task_files` 方法增加两个清理步骤
### 改进
**aide 命令递归查找项目根目录**
- 新增 `find_project_root()` 函数,支持从子目录运行 aide 命令
- 类似 git 查找 `.git` 目录的逻辑:从当前目录向上递归查找
- 查找策略(两遍遍历):
1. 优先查找包含 `flow-status.json` 的目录(活跃任务)
2. 其次查找包含 `config.toml` 的目录
- 解决了会话重启后工作目录变更导致任务状态"丢失"的问题
### 修改的文件
- `aide-program/aide/core/config.py` - 新增 `find_project_root()` 函数
- `aide-program/aide/main.py` - 所有 handler 函数改用 `find_project_root()` 替代 `Path.cwd()`
---
### 新增功能
**全自动任务执行命令 `/aide:auto-run`**

View File

@@ -10,6 +10,63 @@ from tomli_w import dumps as toml_dumps
from aide.core import output
def find_project_root(start_path: Path | None = None) -> Path:
"""递归向上查找包含有效 .aide 目录的项目根目录。
类似于 git 查找 .git 目录的逻辑:从当前目录开始向上遍历,
直到找到包含有效 .aide 目录的父目录。
查找策略(两遍遍历):
1. 第一遍:优先查找包含 flow-status.json 的目录(活跃任务)
2. 第二遍:如果第一遍未找到,查找包含 config.toml 的目录
这样可以确保从子目录运行时,优先找到有活跃任务的项目根目录。
Args:
start_path: 起始路径,默认为当前工作目录
Returns:
找到有效 .aide 目录的父目录路径,如果未找到则返回起始路径
"""
if start_path is None:
start_path = Path.cwd()
start_path = start_path.resolve()
def search_upward(check_fn) -> Path | None:
"""向上遍历查找满足条件的目录"""
current = start_path
while current != current.parent:
if check_fn(current):
return current
current = current.parent
# 检查根目录本身
if check_fn(current):
return current
return None
def has_flow_status(path: Path) -> bool:
"""检查是否有活跃任务状态文件"""
return (path / ".aide" / "flow-status.json").exists()
def has_config(path: Path) -> bool:
"""检查是否有配置文件"""
return (path / ".aide" / "config.toml").exists()
# 第一遍:优先查找有活跃任务的目录
result = search_upward(has_flow_status)
if result is not None:
return result
# 第二遍:查找有配置文件的目录
result = search_upward(has_config)
if result is not None:
return result
# 未找到有效 .aide 目录,返回原始起始路径
return start_path
DEFAULT_CONFIG = """################################################################################
# Aide 配置文件 (config.toml)
################################################################################

View File

@@ -118,6 +118,8 @@ class BranchManager:
- 清空任务原文件 (task.source),保留文件本身
- 备份并删除 flow-status.json
- 备份并删除 decisions/*.json
- 删除 pending-items.json
- 删除流程图目录下的所有文件 (.puml, .plantuml, .png)
"""
# 确保 logs 目录存在
self.logs_dir.mkdir(parents=True, exist_ok=True)
@@ -175,6 +177,25 @@ class BranchManager:
except OSError:
pass
# 6. 删除 pending-items.json
pending_items_path = self.aide_dir / "pending-items.json"
if pending_items_path.exists():
try:
pending_items_path.unlink()
except OSError:
pass
# 7. 删除流程图目录下的所有文件
diagram_path = self.cfg.get_value("flow.diagram_path") or ".aide/diagrams"
diagram_dir = self.root / diagram_path
if diagram_dir.exists() and diagram_dir.is_dir():
for diagram_file in diagram_dir.iterdir():
if diagram_file.is_file() and diagram_file.suffix in (".puml", ".plantuml", ".png"):
try:
diagram_file.unlink()
except OSError:
pass
def load_branches(self) -> BranchesData:
"""加载分支概况"""
if self._data is not None:

View File

@@ -8,7 +8,7 @@ from pathlib import Path
from typing import Any
from aide.core import output
from aide.core.config import ConfigManager
from aide.core.config import ConfigManager, find_project_root
from aide.env.manager import EnvManager
from aide.flow.tracker import FlowTracker
@@ -162,7 +162,7 @@ def build_parser() -> argparse.ArgumentParser:
def handle_init(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
cfg.ensure_config()
cfg.ensure_gitignore()
@@ -174,7 +174,7 @@ def handle_env_default(args: argparse.Namespace) -> bool:
"""aide env无子命令等同于 aide env ensure。"""
if args.env_command is None:
# 无子命令,执行默认的 ensure
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
manager = EnvManager(root, cfg)
return manager.ensure()
@@ -183,7 +183,7 @@ def handle_env_default(args: argparse.Namespace) -> bool:
def handle_env_ensure(args: argparse.Namespace) -> bool:
"""aide env ensure 处理。"""
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
manager = EnvManager(root, cfg)
@@ -202,7 +202,7 @@ def handle_env_ensure(args: argparse.Namespace) -> bool:
def handle_env_list(args: argparse.Namespace) -> bool:
"""aide env list 处理。"""
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
manager = EnvManager(root, cfg)
manager.list_modules()
@@ -211,7 +211,7 @@ def handle_env_list(args: argparse.Namespace) -> bool:
def handle_env_set(args: argparse.Namespace) -> bool:
"""aide env set 处理。"""
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
manager = EnvManager(root, cfg)
@@ -238,7 +238,7 @@ def handle_env_set(args: argparse.Namespace) -> bool:
def handle_config_get(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
value = cfg.get_value(args.key)
if value is None:
@@ -249,7 +249,7 @@ def handle_config_get(args: argparse.Namespace) -> bool:
def handle_config_set(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
parsed_value = _parse_value(args.value)
cfg.set_value(args.key, parsed_value)
@@ -262,49 +262,49 @@ def handle_flow_help(args: argparse.Namespace) -> bool:
def handle_flow_start(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
tracker = FlowTracker(root, cfg)
return tracker.start(args.phase, args.summary)
def handle_flow_next_step(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
tracker = FlowTracker(root, cfg)
return tracker.next_step(args.summary)
def handle_flow_back_step(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
tracker = FlowTracker(root, cfg)
return tracker.back_step(args.reason)
def handle_flow_next_part(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
tracker = FlowTracker(root, cfg)
return tracker.next_part(args.phase, args.summary)
def handle_flow_back_part(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
tracker = FlowTracker(root, cfg)
return tracker.back_part(args.phase, args.reason)
def handle_flow_issue(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
tracker = FlowTracker(root, cfg)
return tracker.issue(args.description)
def handle_flow_error(args: argparse.Namespace) -> bool:
root = Path.cwd()
root = find_project_root()
cfg = ConfigManager(root)
tracker = FlowTracker(root, cfg)
return tracker.error(args.description)
@@ -314,7 +314,7 @@ def handle_flow_status(args: argparse.Namespace) -> bool:
"""aide flow status - 查看当前任务状态。"""
from aide.flow.storage import FlowStorage
root = Path.cwd()
root = find_project_root()
storage = FlowStorage(root)
try:
@@ -346,7 +346,7 @@ def handle_flow_list(args: argparse.Namespace) -> bool:
"""aide flow list - 列出所有任务。"""
from aide.flow.storage import FlowStorage
root = Path.cwd()
root = find_project_root()
storage = FlowStorage(root)
try:
@@ -374,7 +374,7 @@ def handle_flow_show(args: argparse.Namespace) -> bool:
"""aide flow show <task_id> - 查看指定任务的详细状态。"""
from aide.flow.storage import FlowStorage
root = Path.cwd()
root = find_project_root()
storage = FlowStorage(root)
try:

View File

@@ -1,3 +0,0 @@
对aide程序进行一些调整
在收尾清理时删除旧的pending-items还有流程图目录下的所有文件包括plantuml源文件和生成的png文件