From 9db0945b0efdffe5e40fae9525034cc84ef044d0 Mon Sep 17 00:00:00 2001 From: adil Date: Wed, 15 Apr 2026 03:38:38 +0530 Subject: [PATCH] fix: address follow-up review comments from @illegalcall 1. Fix ao start regression: when target path differs from cwd, run autoCreateConfig on the target (which is a git repo) instead of cwd (which may not be). Removes the double-create pattern that added a second project entry. 2. Gate remaining PR/CI sections in orchestrator-prompt: PR Takeover, PR Review Flow, Bulk Issue Processing, and Monitoring Progress details are now wrapped in project.repo checks so repo-less projects don't get contradictory instructions. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/src/commands/start.ts | 13 ++++----- packages/core/src/orchestrator-prompt.ts | 36 +++++++++++++++++------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/packages/cli/src/commands/start.ts b/packages/cli/src/commands/start.ts index 5c2155f78..f47d4b1ff 100644 --- a/packages/cli/src/commands/start.ts +++ b/packages/cli/src/commands/start.ts @@ -1278,17 +1278,14 @@ export function registerStart(program: Command): void { } if (!configPath) { - // No config anywhere — auto-create in cwd, then add the path as project - config = await autoCreateConfig(cwd()); - // If the path is different from cwd, add it as a second project if (resolve(cwd()) !== resolvedPath) { - const addedId = await addProjectToConfig(config, resolvedPath); - config = loadConfig(config.configPath); - projectId = addedId; - project = config.projects[projectId]; + // Target path differs from cwd — create config at the target repo + config = await autoCreateConfig(resolvedPath); } else { - ({ projectId, project } = await resolveProject(config)); + // cwd is the target — auto-create config here + config = await autoCreateConfig(cwd()); } + ({ projectId, project } = await resolveProject(config)); } else { config = loadConfig(configPath); diff --git a/packages/core/src/orchestrator-prompt.ts b/packages/core/src/orchestrator-prompt.ts index 1a70d1ff0..7daaab4cc 100644 --- a/packages/core/src/orchestrator-prompt.ts +++ b/packages/core/src/orchestrator-prompt.ts @@ -126,7 +126,7 @@ ao session kill ${project.sessionPrefix}-1 ${cmdRows.join("\n")}`); // Session Management - sections.push(`## Session Management + const sessionMgmt = [`## Session Management ### Spawning Sessions @@ -145,19 +145,21 @@ ao spawn --prompt "Add rate limiting to the /api/upload endpoint" ### Monitoring Progress Use \`ao status\` to see: -- Current session status (working, pr_open, review_pending, etc.) +- Current session status (working, pr_open, review_pending, etc.)${project.repo ? ` - PR state (open/merged/closed) - CI status (passing/failing/pending) - Review decision (approved/changes_requested/pending) -- Unresolved comments count +- Unresolved comments count` : ""} ### Sending Messages Send instructions to a running agent: \`\`\`bash ao send ${project.sessionPrefix}-1 "Please address the review comments on your PR" -\`\`\` +\`\`\``]; + if (project.repo) { + sessionMgmt.push(` ### PR Takeover If a worker session needs to continue work on an existing PR: @@ -169,8 +171,10 @@ ao spawn --claim-pr 123 This updates AO metadata, switches the worker worktree onto the PR branch, and lets lifecycle reactions keep routing CI and review feedback to that worker session. -Never claim a PR into \`${project.sessionPrefix}-orchestrator\`. If a PR needs implementation or takeover, delegate it to a worker session instead. +Never claim a PR into \`${project.sessionPrefix}-orchestrator\`. If a PR needs implementation or takeover, delegate it to a worker session instead.`); + } + sessionMgmt.push(` ### Investigation Workflow When debugging or triaging from the orchestrator session: @@ -186,6 +190,8 @@ Remove completed sessions: ao session cleanup -p ${projectId} # Kill sessions where PR is merged or issue is closed \`\`\``); + sections.push(sessionMgmt.join("\n")); + // Dashboard sections.push(`## Dashboard @@ -223,35 +229,45 @@ ${reactionLines.join("\n")}`); } // Workflows - sections.push(`## Common Workflows + const workflows = [`## Common Workflows`]; + if (project.repo) { + workflows.push(` ### Bulk Issue Processing 1. Get list of issues from tracker (GitHub/Linear/etc.) 2. Use \`ao batch-spawn\` to spawn sessions for each issue 3. Monitor with \`ao status\` or the dashboard 4. Agents will fetch, implement, test, PR, and respond to reviews -5. Use \`ao session cleanup\` when PRs are merged +5. Use \`ao session cleanup\` when PRs are merged`); + } + workflows.push(` ### Handling Stuck Agents 1. Check \`ao status\` for sessions in "stuck" or "needs_input" state 2. Attach with \`ao session attach \` to see what they're doing 3. Send clarification or instructions with \`ao send '...'\` -4. Or kill and respawn with fresh context if needed +4. Or kill and respawn with fresh context if needed`); + if (project.repo) { + workflows.push(` ### PR Review Flow 1. Agent creates PR and pushes 2. CI runs automatically 3. If CI fails: reaction auto-sends fix instructions to agent 4. If reviewers request changes: reaction auto-sends comments to agent -5. When approved + green: notify human to merge (unless auto-merge enabled) +5. When approved + green: notify human to merge (unless auto-merge enabled)`); + } + workflows.push(` ### Manual Intervention When an agent needs human judgment: 1. You'll get a notification (desktop/slack/webhook) 2. Check the dashboard or \`ao status\` for details 3. Attach to the session if needed: \`ao session attach \` 4. Send instructions: \`ao send '...'\` -5. Or handle the human-only action yourself (merge PR, close issue, etc.) while keeping implementation in worker sessions.`); +5. Or handle the human-only action yourself${project.repo ? " (merge PR, close issue, etc.)" : ""} while keeping implementation in worker sessions.`); + + sections.push(workflows.join("\n")); // Tips sections.push(`## Tips