@ronkovic/aad 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronkovic/aad",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Autonomous Agent Development Orchestrator - Multi-agent TDD pipeline powered by Claude",
5
5
  "module": "src/main.ts",
6
6
  "type": "module",
@@ -102,10 +102,10 @@ export async function cleanupWorktrees(
102
102
  await worktreeManager.pruneWorktrees();
103
103
  logger.info("Pruned orphaned worktrees");
104
104
 
105
- // 4. Cleanup orphaned branches
105
+ // 4. Cleanup orphaned branches (always force-delete — AAD branches are safe to remove)
106
106
  const deletedBranches = runId
107
- ? await branchManager.cleanupOrphanBranches(runId)
108
- : await branchManager.cleanupOrphanBranches();
107
+ ? await branchManager.cleanupOrphanBranches(runId, true)
108
+ : await branchManager.cleanupOrphanBranches(undefined, true);
109
109
 
110
110
  if (deletedBranches.length > 0) {
111
111
  console.log(`\nDeleted ${deletedBranches.length} orphan branch(es):`);
@@ -122,7 +122,15 @@ export async function resumeRun(app: App, runIdStr: string): Promise<void> {
122
122
  stores: { runStore: stores.runStore, taskStore: stores.taskStore },
123
123
  logger,
124
124
  });
125
- registerTaskDispatchHandler({ app, runId, parentBranch: runState.parentBranch });
125
+ // Check if parent worktree exists from a previous run
126
+ const parentWorktreePath = `${process.cwd()}/.aad/worktrees/parent-${runId}`;
127
+ const parentWorktreeExists = await Bun.file(`${parentWorktreePath}/.git`).exists();
128
+ registerTaskDispatchHandler({
129
+ app,
130
+ runId,
131
+ parentBranch: runState.parentBranch,
132
+ parentWorktreePath: parentWorktreeExists ? parentWorktreePath : undefined,
133
+ });
126
134
 
127
135
  // 6. Dispatcher.start()
128
136
  dispatcher.start();
@@ -144,8 +144,17 @@ export async function runPipeline(app: App, requirementsPath: string, keepWorktr
144
144
  logger,
145
145
  });
146
146
 
147
- // 5. Register task dispatch handler (shared with resume)
148
- registerTaskDispatchHandler({ app, runId, parentBranch });
147
+ // 5. Create parent worktree for merging task branches
148
+ let parentWorktreePath: string | undefined;
149
+ try {
150
+ parentWorktreePath = await worktreeManager.createParentWorktree(runId, parentBranch);
151
+ logger.info({ parentWorktreePath }, "Parent worktree created for merging");
152
+ } catch (error) {
153
+ logger.warn({ error }, "Failed to create parent worktree, using repo root as fallback");
154
+ }
155
+
156
+ // 5.5. Register task dispatch handler (shared with resume)
157
+ registerTaskDispatchHandler({ app, runId, parentBranch, parentWorktreePath });
149
158
 
150
159
  // 6. 進捗表示
151
160
  const progressSpinner = createSpinner("Executing tasks...");
@@ -25,6 +25,9 @@ export interface TaskDispatchContext {
25
25
  app: App;
26
26
  runId: RunId;
27
27
  parentBranch: string;
28
+ /** Path to the parent worktree where task branches are merged into.
29
+ * If not provided, falls back to process.cwd() (repo root). */
30
+ parentWorktreePath?: string;
28
31
  }
29
32
 
30
33
  /**
@@ -32,7 +35,8 @@ export interface TaskDispatchContext {
32
35
  * Handles memory gate, worker state, worktree creation, and TDD pipeline execution.
33
36
  */
34
37
  export function registerTaskDispatchHandler(ctx: TaskDispatchContext): void {
35
- const { app, runId, parentBranch } = ctx;
38
+ const { app, runId, parentBranch, parentWorktreePath } = ctx;
39
+ const mergeTarget = parentWorktreePath ?? process.cwd();
36
40
  const { eventBus, logger, config, processManager, worktreeManager, providerRegistry, stores } = app;
37
41
 
38
42
  let memoryGateLock: Promise<void> = Promise.resolve();
@@ -63,7 +67,7 @@ export function registerTaskDispatchHandler(ctx: TaskDispatchContext): void {
63
67
 
64
68
  const provider = providerRegistry.getProvider("implementer");
65
69
  const result = await executeTddPipeline(
66
- task, workspace, branchName, parentBranch, process.cwd(),
70
+ task, workspace, branchName, parentBranch, mergeTarget,
67
71
  runId, app.config, provider, app.mergeService, eventBus,
68
72
  );
69
73