From 4cc4236fe6a3c1bf665f02e15683771d1aeeec6c Mon Sep 17 00:00:00 2001 From: "Rai (Michael Pokorny)" Date: Wed, 25 Jun 2025 00:27:16 -0700 Subject: [PATCH] wip --- ...15-agent-worktree-sandbox-configuration.md | 4 ++-- .../tools/manager_utils/agentydragon_task.py | 22 +++++++++++++------ agentydragon/tools/manager_utils/tasklib.py | 3 +++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/agentydragon/tasks/15-agent-worktree-sandbox-configuration.md b/agentydragon/tasks/15-agent-worktree-sandbox-configuration.md index ca2b7c451b..3bc53b2825 100644 --- a/agentydragon/tasks/15-agent-worktree-sandbox-configuration.md +++ b/agentydragon/tasks/15-agent-worktree-sandbox-configuration.md @@ -1,9 +1,9 @@ +++ id = "15" title = "Agent Worktree Sandbox Configuration" -status = "Done" +status = "Merged" dependencies = "02,07,09,11,14,29" -last_updated = "2025-06-25T12:00:00.000000" +last_updated = "2025-06-25T07:26:13.570520" +++ # Task 15: Agent Worktree Sandbox Configuration diff --git a/agentydragon/tools/manager_utils/agentydragon_task.py b/agentydragon/tools/manager_utils/agentydragon_task.py index 6bce5ce4d2..f7e3229d3c 100644 --- a/agentydragon/tools/manager_utils/agentydragon_task.py +++ b/agentydragon/tools/manager_utils/agentydragon_task.py @@ -7,7 +7,7 @@ import sys from datetime import datetime import click -from tasklib import load_task, repo_root, save_task, task_dir, TaskMeta +from tasklib import load_task, repo_root, save_task, task_dir, TaskMeta, worktree_dir import shutil try: @@ -105,7 +105,7 @@ def status(): if subprocess.run(['git', 'merge-base', '--is-ancestor', b, 'agentydragon'], cwd=root).returncode == 0: merged_flag = 'Y' # worktree detection - wt_dir = task_dir() / '.worktrees' / slug + wt_dir = worktree_dir() / slug wt_info = 'none' if wt_dir.exists(): st = subprocess.run(['git', 'status', '--porcelain'], cwd=wt_dir, @@ -212,15 +212,20 @@ def set_deps(task_id, deps): def dispose(task_id): """Dispose worktree and delete branch for TASK_ID(s)""" root = repo_root() - wt_base = task_dir() / '.worktrees' + wt_base = worktree_dir() for tid in task_id: # Remove any matching worktree directories - for wt_dir in wt_base.glob(f'{tid}-*'): + g = f'{tid}-*' + matching_wts = wt_base.glob(g) + for wt_dir in matching_wts: + click.echo(f"Disposing worktree {wt_dir}") # unregister worktree; then delete the directory if still present rel = wt_dir.relative_to(root) subprocess.run(['git', 'worktree', 'remove', str(rel), '--force'], cwd=root) if wt_dir.exists(): shutil.rmtree(wt_dir) + else: + print(f"No worktrees matching {g} in {wt_base}") # prune any stale worktree entries subprocess.run(['git', 'worktree', 'prune'], cwd=root) # Delete any matching branches @@ -230,9 +235,12 @@ def dispose(task_id): ['git', 'for-each-ref', '--format=%(refname:short)', ref_pattern], capture_output=True, text=True, cwd=root ).stdout.splitlines() - for br in branches: - if br: - subprocess.run(['git', 'branch', '-D', br], cwd=root) + branches = [br for br in branches if br] + if branches: + click.echo(f"Disposing branches: {branches}") + subprocess.run(['git', 'branch', '-D', *branches], cwd=root) + else: + click.echo(f"No branches matching {ref_pattern}") click.echo(f'Disposed task {tid}') @cli.command() diff --git a/agentydragon/tools/manager_utils/tasklib.py b/agentydragon/tools/manager_utils/tasklib.py index 259495e6aa..a4515369b0 100644 --- a/agentydragon/tools/manager_utils/tasklib.py +++ b/agentydragon/tools/manager_utils/tasklib.py @@ -18,6 +18,9 @@ def repo_root(): def task_dir(): return repo_root() / "agentydragon/tasks" +def worktree_dir(): + return task_dir() / ".worktrees" + class TaskMeta(BaseModel): id: str title: str