refactor: unify errand worktree paths to use agent-workdirs/<alias>/

Errands now create worktrees via ProcessManager.createWorktreesForProjects()
into agent-workdirs/<alias>/<project.name>/ instead of repos/<project>/.cw-worktrees/<errandId>.
This makes getAgentWorkdir + resolveAgentCwd work correctly for all agent types.

Key changes:
- Extract createWorktreesForProjects() from createProjectWorktrees() in ProcessManager
- Add resolveAgentCwd() to ProcessManager (probes for .cw/output in subdirs)
- Add projectId to SpawnAgentOptions for single-project agents (errands)
- Skip auto-cleanup for errand agents (worktrees persist for merge/abandon)
- Errand router uses agentManager.delete() for cleanup instead of SimpleGitWorktreeManager
- Remove cwd parameter from sendUserMessage (resolves via worktreeId)
- Add pruneProjectRepos() to CleanupManager for errand worktree refs
This commit is contained in:
Lukas May
2026-03-07 00:02:27 +01:00
parent b17c0a2b4f
commit c52fa86542
7 changed files with 133 additions and 101 deletions

View File

@@ -534,7 +534,7 @@ export class MockAgentManager implements AgentManager {
* Deliver a user message to a running errand agent.
* Mock implementation: no-op (simulates message delivery without actual process interaction).
*/
async sendUserMessage(agentId: string, _message: string, _cwd?: string): Promise<void> {
async sendUserMessage(agentId: string, _message: string): Promise<void> {
const record = this.agents.get(agentId);
if (!record) {
throw new Error(`Agent '${agentId}' not found`);