Skip to content

feat: enhance repair command to recreate core agents and default workspace#324

Open
aronchick wants to merge 1 commit intodlorenc:mainfrom
aronchick:work/bold-elephant
Open

feat: enhance repair command to recreate core agents and default workspace#324
aronchick wants to merge 1 commit intodlorenc:mainfrom
aronchick:work/bold-elephant

Conversation

@aronchick
Copy link
Copy Markdown
Contributor

Summary

Enhance the repair command to be more comprehensive by ensuring core agents and a default workspace exist after cleanup. This addresses ROADMAP.md P1 "Agent restart" by making repair more robust and reducing the need for manual intervention.

Changes

CLI (internal/cli/cli.go)

  • Added ensureCoreAgents() helper to check and create missing core agents
  • Added createCoreAgent() to create individual core agents (supervisor, merge-queue, pr-shepherd)
  • Added ensureDefaultWorkspace() to create default workspace if none exist
  • Updated localRepair() to call these helpers after cleanup
  • Improved output format to show removed/cleaned/created items separately

Daemon (internal/daemon/daemon.go)

  • Added ensureCoreAgents() method mirroring CLI logic
  • Added spawnCoreAgent() to spawn individual core agents
  • Added ensureDefaultWorkspace() to create default workspace via tmux
  • Updated handleRepairState() to recreate missing agents
  • Updated response to include agents_created and workspaces_created counts

Tests (internal/cli/cli_test.go)

  • TestRepairEnsuringCoreAgents: Verifies supervisor and merge-queue creation
  • TestRepairEnsuringPRShepherdInForkMode: Verifies fork mode behavior
  • TestRepairDoesNotDuplicateAgents: Ensures existing agents aren't replaced

Behavior

Before

$ multiclaude repair
Repairing state...
✓ Local repair completed
  Removed 2 dead agent(s)
  Fixed 3 issue(s)

After

$ multiclaude repair
Repairing state...

Ensuring core agents for repository: my-repo
  Creating missing supervisor agent...
  Creating missing merge-queue agent...
  Creating default workspace 'my-default-2'...

✓ Local repair completed
  Removed: 2 dead agent(s)
  Cleaned: 3 orphaned resource(s)
  Created: 2 core agent(s)
  Created: 1 default workspace(s)

Key Features

  1. Recreates missing supervisor: If supervisor agent is missing, creates it
  2. Recreates merge-queue/pr-shepherd: Based on fork mode configuration
  3. Creates default workspace: If no workspaces exist, creates "my-default-2"
  4. No duplication: Skips agents/workspaces that already exist
  5. Better visibility: Shows what was removed vs created

Testing

All tests pass including new comprehensive repair tests:

$ go test ./...
ok  	github.com/dlorenc/multiclaude/internal/cli	10.200s
ok  	github.com/dlorenc/multiclaude/internal/daemon	3.809s

Alignment with ROADMAP.md

This change aligns with ROADMAP.md P1 "Agent restart": making the repair command more robust so agents can be automatically restored without manual intervention. This improves the "Reliable worker lifecycle" goal.

🤖 Generated with Claude Code

…space

Improve the repair command to be more comprehensive by ensuring core
agents and a default workspace exist after cleanup. This enhancement
aligns with ROADMAP.md P1 "Agent restart" by making repair more robust
and reducing the need for manual intervention.

Changes:
- CLI: Add ensureCoreAgents() and ensureDefaultWorkspace() helpers
- CLI: Update localRepair() to recreate missing core agents
- CLI: Create default workspace "my-default-2" if none exist
- Daemon: Add ensureCoreAgents() and ensureDefaultWorkspace() methods
- Daemon: Update handleRepairState() to recreate missing agents
- Both: Improve output to show what was removed and what was created
- Tests: Add comprehensive tests for all scenarios

Key Features:
1. Recreates missing supervisor agent if absent
2. Recreates missing merge-queue (non-fork) or pr-shepherd (fork)
3. Creates default workspace if no workspaces exist
4. Does not duplicate existing agents/workspaces
5. Provides detailed output showing:
   - Removed: dead agents
   - Cleaned: orphaned resources
   - Created: core agents and workspaces

Test Coverage:
- TestRepairEnsuringCoreAgents: Verifies core agents are created
- TestRepairEnsuringPRShepherdInForkMode: Fork mode verification
- TestRepairDoesNotDuplicateAgents: Prevents duplicates

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@buggtb
Copy link
Copy Markdown

buggtb commented Jan 29, 2026

Superseded by PR #327

PR #327 contains the same feature with an additional lint fix. This PR is superseded and likely doesn't need to be merged separately.

🤖 Merge-queue agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants