diff --git a/.aide/flow-status.json b/.aide/flow-status.json index f9914a6..971fef3 100644 --- a/.aide/flow-status.json +++ b/.aide/flow-status.json @@ -1,7 +1,7 @@ { "task_id": "2025-12-15T17-28-53", "current_phase": "impl", - "current_step": 10, + "current_step": 11, "started_at": "2025-12-15T17:28:53+08:00", "history": [ { @@ -82,6 +82,14 @@ "step": 10, "summary": "流程设计完成,进入实现环节", "git_commit": "5f27bb7424cc5ce2f18ab30a9f1a0ad9a626b604" + }, + { + "timestamp": "2025-12-15T18:09:36+08:00", + "action": "next-step", + "phase": "impl", + "step": 11, + "summary": "子计划1: 配置系统增强完成 - 自文档化配置模板、gitignore配置、plantuml.jar", + "git_commit": "79facec0a3db9ffcf936772930cc695ca9bf263d" } ] } diff --git a/.aide/flow-status.lock b/.aide/flow-status.lock index 667f640..1df1ee0 100755 --- a/.aide/flow-status.lock +++ b/.aide/flow-status.lock @@ -1 +1 @@ -119009 \ No newline at end of file +120170 \ No newline at end of file diff --git a/aide-program/aide/flow/storage.py b/aide-program/aide/flow/storage.py index 22d59c6..aeb0988 100644 --- a/aide-program/aide/flow/storage.py +++ b/aide-program/aide/flow/storage.py @@ -89,3 +89,58 @@ class FlowStorage: except Exception as exc: raise FlowError(f"归档旧状态失败: {exc}") + def list_all_tasks(self) -> list[dict]: + """列出所有任务(当前 + 归档),返回按时间倒序排列的任务摘要列表。""" + tasks = [] + + # 当前任务 + current = self.load_status() + if current is not None: + tasks.append({ + "task_id": current.task_id, + "phase": current.current_phase, + "started_at": current.started_at, + "summary": current.history[0].summary if current.history else "", + "is_current": True, + }) + + # 归档任务 + if self.logs_dir.exists(): + for f in self.logs_dir.glob("flow-status.*.json"): + try: + raw = f.read_text(encoding="utf-8") + data = json.loads(raw) + status = FlowStatus.from_dict(data) + tasks.append({ + "task_id": status.task_id, + "phase": status.current_phase, + "started_at": status.started_at, + "summary": status.history[0].summary if status.history else "", + "is_current": False, + }) + except Exception: + continue + + # 按 task_id 倒序(task_id 是时间戳格式) + tasks.sort(key=lambda x: x["task_id"], reverse=True) + return tasks + + def load_task_by_id(self, task_id: str) -> FlowStatus | None: + """根据 task_id 加载任务状态(当前或归档)。""" + # 先检查当前任务 + current = self.load_status() + if current is not None and current.task_id == task_id: + return current + + # 检查归档 + archive_path = self.logs_dir / f"flow-status.{task_id}.json" + if archive_path.exists(): + try: + raw = archive_path.read_text(encoding="utf-8") + data = json.loads(raw) + return FlowStatus.from_dict(data) + except Exception as exc: + raise FlowError(f"读取归档任务失败: {exc}") + + return None + diff --git a/aide-program/aide/main.py b/aide-program/aide/main.py index 98546a5..2ac6ea0 100644 --- a/aide-program/aide/main.py +++ b/aide-program/aide/main.py @@ -127,6 +127,19 @@ def build_parser() -> argparse.ArgumentParser: flow_error.add_argument("description", help="错误描述") flow_error.set_defaults(func=handle_flow_error) + # aide flow status + flow_status = flow_sub.add_parser("status", help="查看当前任务状态") + flow_status.set_defaults(func=handle_flow_status) + + # aide flow list + flow_list = flow_sub.add_parser("list", help="列出所有任务") + flow_list.set_defaults(func=handle_flow_list) + + # aide flow show + flow_show = flow_sub.add_parser("show", help="查看指定任务的详细状态") + flow_show.add_argument("task_id", help="任务 ID(时间戳格式,如 20251215-103000)") + flow_show.set_defaults(func=handle_flow_show) + flow_parser.set_defaults(func=handle_flow_help) # aide decide @@ -297,6 +310,98 @@ def handle_flow_error(args: argparse.Namespace) -> bool: return tracker.error(args.description) +def handle_flow_status(args: argparse.Namespace) -> bool: + """aide flow status - 查看当前任务状态。""" + from aide.flow.storage import FlowStorage + + root = Path.cwd() + storage = FlowStorage(root) + + try: + status = storage.load_status() + except Exception as exc: + output.err(f"读取状态失败: {exc}") + return False + + if status is None: + output.info("当前无活跃任务") + return True + + # 获取最新的历史条目 + latest = status.history[-1] if status.history else None + + output.info(f"任务 ID: {status.task_id}") + output.info(f"环节: {status.current_phase}") + output.info(f"步骤: {status.current_step}") + output.info(f"开始时间: {status.started_at}") + if latest: + output.info(f"最新操作: {latest.summary}") + output.info(f"操作时间: {latest.timestamp}") + if latest.git_commit: + output.info(f"Git 提交: {latest.git_commit[:7]}") + return True + + +def handle_flow_list(args: argparse.Namespace) -> bool: + """aide flow list - 列出所有任务。""" + from aide.flow.storage import FlowStorage + + root = Path.cwd() + storage = FlowStorage(root) + + try: + tasks = storage.list_all_tasks() + except Exception as exc: + output.err(f"读取任务列表失败: {exc}") + return False + + if not tasks: + output.info("暂无任务记录") + return True + + output.info("任务列表:") + for i, task in enumerate(tasks, 1): + marker = "*" if task["is_current"] else " " + phase = task["phase"] + summary = task["summary"][:30] + "..." if len(task["summary"]) > 30 else task["summary"] + print(f" {marker}[{i}] {task['task_id']} ({phase}) {summary}") + + output.info("提示: 使用 aide flow show 查看详细状态") + return True + + +def handle_flow_show(args: argparse.Namespace) -> bool: + """aide flow show - 查看指定任务的详细状态。""" + from aide.flow.storage import FlowStorage + + root = Path.cwd() + storage = FlowStorage(root) + + try: + status = storage.load_task_by_id(args.task_id) + except Exception as exc: + output.err(f"读取任务失败: {exc}") + return False + + if status is None: + output.err(f"未找到任务: {args.task_id}") + return False + + output.info(f"任务 ID: {status.task_id}") + output.info(f"当前环节: {status.current_phase}") + output.info(f"当前步骤: {status.current_step}") + output.info(f"开始时间: {status.started_at}") + output.info("") + output.info("历史记录:") + + for entry in status.history: + commit_str = f" [{entry.git_commit[:7]}]" if entry.git_commit else "" + print(f" [{entry.phase}] {entry.summary}{commit_str}") + print(f" {entry.timestamp} ({entry.action})") + + return True + + def handle_decide_help(args: argparse.Namespace) -> bool: print("usage: aide decide {submit,result} ...") print("")