Commit Graph

602 Commits

Author SHA1 Message Date
Lukas May
37a90db28c test(06-02): add comprehensive CoordinationManager tests
18 tests covering:
- Queue management (queueMerge, getQueueState)
- Dependency ordering (getNextMergeable with priority)
- Success path (processMerges with clean merges)
- Conflict handling (detect conflicts, create resolution task, send message)
- Error handling (missing repositories, missing agent)

Exports DefaultCoordinationManager from coordination module index.
2026-01-30 21:09:29 +01:00
Lukas May
4535707bc8 feat(06-02): enhance conflict bounce-back with agent messaging
Adds MessageRepository to DefaultCoordinationManager for conflict notification:
- Creates info message to agent when merge conflict occurs
- Message includes conflicting file list and resolution instructions
- System-generated messages use senderType='user' with null senderId
- Refactors conflict description into cleaner array.join format
2026-01-30 21:07:46 +01:00
Lukas May
6d7894bde4 feat(06-02): implement DefaultCoordinationManager adapter
Implements CoordinationManager interface with:
- In-memory merge queue with dependency tracking
- Dependency-ordered merging (getNextMergeable)
- Merge queue state tracking (queued, in_progress, merged, conflicted)
- Event emission for all merge lifecycle events
- Basic conflict handling (creates resolution task)
2026-01-30 21:06:54 +01:00
Lukas May
efcffef3ec docs(06-01): complete coordination events & port plan
Tasks completed: 2/2
- Add coordination domain events to event types
- Create CoordinationManager port interface

SUMMARY: .planning/phases/06-coordination/06-01-SUMMARY.md
2026-01-30 21:05:17 +01:00
Lukas May
0570d21ad6 feat(06-01): add CoordinationManager port interface
- MergeQueueItem type for merge queue entries
- MergeStatus type: queued | in_progress | merged | conflict
- MergeResult type with task context
- CoordinationManager interface with methods:
  - queueMerge: queue completed task for merge
  - getNextMergeable: get next task with resolved dependencies
  - processMerges: process all ready merges
  - handleConflict: bounce-back for conflict resolution
  - getQueueState: query queue by status
2026-01-30 21:03:54 +01:00
Lukas May
94130a6661 feat(06-01): add coordination domain events for merge lifecycle
- MergeQueuedEvent: completed task queued for merge
- MergeStartedEvent: merge attempt begins
- MergeCompletedEvent: merge succeeds
- MergeConflictedEvent: merge has conflicts (triggers bounce-back)
2026-01-30 21:03:02 +01:00
Lukas May
22572f410f docs(06): create phase plan
Phase 06: Coordination
- 3 plans in 3 waves
- 06-01: Coordination Events & Port (Wave 1)
- 06-02: CoordinationManager Adapter (Wave 2)
- 06-03: tRPC & CLI Integration (Wave 3)
- Ready for execution
2026-01-30 20:58:23 +01:00
Lukas May
e941561ecf docs(05): complete task-dispatch phase 2026-01-30 20:51:11 +01:00
Lukas May
a4484eb67d docs(05-05): complete message & dispatch CLI plan
Tasks completed: 2/2
- Add message and dispatch tRPC procedures
- Add message and dispatch CLI commands

Phase 5 complete: all task dispatch requirements implemented.

SUMMARY: .planning/phases/05-task-dispatch/05-05-SUMMARY.md
2026-01-30 20:50:18 +01:00
Lukas May
211411e795 feat(05-05): add message and dispatch CLI commands
- Add message command group: list, read, respond
- Add dispatch command group: queue, next, status, complete
- Message list shows pending count and filters by agent/status
- Dispatch status shows ready tasks with priorities
2026-01-30 20:48:22 +01:00
Lukas May
e0e03eef86 feat(05-05): add message and dispatch tRPC procedures
- Add messageRepository and dispatchManager to TRPCContext
- Add requireMessageRepository and requireDispatchManager helpers
- Add message procedures: listMessages, getMessage, respondToMessage
- Add dispatch procedures: queueTask, dispatchNext, getQueueState, completeTask
2026-01-30 20:47:07 +01:00
Lukas May
099f9b6353 docs(05-04): complete DispatchManager adapter plan
Tasks completed: 3/3
- Implement dependency checking algorithm
- Implement dispatchNext and queue state
- Add tests and wire up exports

SUMMARY: .planning/phases/05-task-dispatch/05-04-SUMMARY.md
2026-01-30 20:44:17 +01:00
Lukas May
364ffc357b test(05-04): add DispatchManager tests and wire up exports
- Add 14 comprehensive tests for DefaultDispatchManager
- Test queue(), getNextDispatchable(), completeTask(), blockTask()
- Test dispatchNext() with agent dispatch flow
- Test getQueueState() for queue visibility
- Test priority ordering and dependency scenario
- Export DefaultDispatchManager from dispatch module
2026-01-30 20:42:38 +01:00
Lukas May
e924fb655a feat(05-04): implement DefaultDispatchManager with dependency checking
- Add DefaultDispatchManager class implementing DispatchManager interface
- Implement queue() with task fetching and event emission
- Implement getNextDispatchable() with priority-based ordering
- Implement completeTask() and blockTask() with status updates
- Implement dispatchNext() for agent assignment
- Implement getQueueState() for queue visibility
- Use in-memory Map for queue management
2026-01-30 20:40:34 +01:00
Lukas May
61802d795f docs(05-01): complete message schema & repository plan
Tasks completed: 2/2
- Add messages table to schema
- Create MessageRepository port and adapter

SUMMARY: .planning/phases/05-task-dispatch/05-01-SUMMARY.md
2026-01-30 20:37:44 +01:00
Lukas May
4974fda6fa docs(05-02): complete task visibility plan
Tasks completed: 2/2
- Add task tRPC procedures (listTasks, getTask, updateTaskStatus)
- Add task CLI commands (list, get, status)

SUMMARY: .planning/phases/05-task-dispatch/05-02-SUMMARY.md
2026-01-30 20:36:47 +01:00
Lukas May
deec438990 docs(05-03): complete DispatchManager port interface plan
Tasks completed: 2/2
- Create DispatchManager port interface
- Add dispatch domain events

SUMMARY: .planning/phases/05-task-dispatch/05-03-SUMMARY.md
2026-01-30 20:35:21 +01:00
Lukas May
19dc75c3f4 feat(05-01): add MessageRepository port and adapter
- Create MessageRepository port interface with CRUD and query methods
- Implement DrizzleMessageRepository adapter with nanoid generation
- Add findBySender/findByRecipient for participant-based queries
- Add findPendingForUser for unread user notifications
- Add findRequiringResponse for messages awaiting reply
- Add findReplies for message threading support
- Add 23 tests covering all operations and edge cases
- Update test-helpers with messages table schema
- Re-export from index files following AgentRepository pattern
2026-01-30 20:35:09 +01:00
Lukas May
586f7caa7a feat(05-02): add task CLI commands
- Add `cw task list --plan <planId>` command
  - Display tasks as table: name, status, type, priority
  - Show count of pending/in_progress/completed/blocked
- Add `cw task get <taskId>` command
  - Display full task details: id, name, description, type, priority, status, order, timestamps
- Add `cw task status <taskId> <status>` command
  - Validate status is one of: pending, in_progress, completed, blocked
  - Confirm status update
2026-01-30 20:34:57 +01:00
Lukas May
f54ec5e07e feat(05-03): add dispatch domain events
- TaskQueuedEvent for task queue operations
- TaskDispatchedEvent when task assigned to agent
- TaskCompletedEvent for task completion with success/failure
- TaskBlockedEvent for blocked tasks with reason
2026-01-30 20:33:36 +01:00
Lukas May
9f24c1ffc0 feat(05-02): add task tRPC procedures
- Add TaskRepository to TRPCContext (optional, same pattern as AgentManager)
- Add requireTaskRepository helper function
- Add listTasks procedure (query tasks by planId, ordered by order field)
- Add getTask procedure (get single task by ID, throws NOT_FOUND)
- Add updateTaskStatus procedure (update task status to pending/in_progress/completed/blocked)
2026-01-30 20:33:26 +01:00
Lukas May
b2e7c2920f feat(05-03): create DispatchManager port interface
- QueuedTask type with priority and dependencies
- DispatchResult type for dispatch operation outcomes
- DispatchManager interface with queue/dispatch/complete/block methods
- Follows hexagonal architecture pattern (same as EventBus, AgentManager)
2026-01-30 20:32:43 +01:00
Lukas May
f873a32ff4 feat(05-01): add messages table to schema
- Add messages table with sender/recipient pattern for agent-user communication
- Support message types: question, info, error, response
- Add requiresResponse flag and status tracking (pending, read, responded)
- Include parentMessageId for threading responses to original questions
- Add relations for sender/recipient agents and message threading
2026-01-30 20:32:31 +01:00
Lukas May
14f2e472f8 docs(05-01): improve message schema with sender/recipient and optional response 2026-01-30 20:30:20 +01:00
Lukas May
e5ae103ef1 docs(roadmap): update Phase 5 plans 2026-01-30 20:22:46 +01:00
Lukas May
7b155ecc28 docs(05): create phase 5 plan - task dispatch
Phase 05: Task Dispatch
- 5 plans in 3 waves
- 3 parallel (Wave 1), 1 sequential (Wave 2), 1 sequential (Wave 3)
- Ready for execution

Requirements covered:
- AGENT-06: Message queue for agent questions
- TASK-01: Task status visibility
- TASK-04: Dependency-ordered dispatch
- TASK-05: Work queue for agents
2026-01-30 20:22:17 +01:00
Lukas May
20d867d980 docs(04): complete agent-lifecycle phase
Mark Phase 4 requirements as Complete:
- AGENT-01: Spawn agent with task assignment
- AGENT-02: Stop running agent
- AGENT-03: List agents with status
- AGENT-04: Session persistence
- AGENT-05: Background mode
- AGENT-07: CLI mode with JSON output
2026-01-30 20:16:03 +01:00
Lukas May
e1ad5e8646 docs(04-04): complete tRPC integration & CLI commands plan
Tasks completed: 3/3
- Add AgentManager to tRPC context
- Add agent procedures to tRPC router
- Add agent CLI commands

Phase 4 (Agent Lifecycle) now complete - all 4 plans finished.

SUMMARY: .planning/phases/04-agent-lifecycle/04-04-SUMMARY.md
2026-01-30 20:14:55 +01:00
Lukas May
4d8916091f feat(04-04): add agent CLI commands
- Replace placeholder agent command with proper subcommands
- Add agent spawn command with --name, --task, --cwd options
- Add agent stop command to stop running agents
- Add agent list command to show all agents
- Add agent get command for detailed agent info
- Add agent resume command for waiting agents
- Add agent result command to get execution results
- All commands use tRPC client for type-safe communication
2026-01-30 20:13:01 +01:00
Lukas May
16f85cd22f feat(04-04): add agent procedures to tRPC router
- Add spawnAgentInputSchema for spawn input validation
- Add agentIdentifierSchema for name/id lookup
- Add resumeAgentInputSchema for resume operations
- Add resolveAgent helper for name/id resolution
- Add requireAgentManager helper for context validation
- Add 7 agent procedures: spawn, stop, list, get, getByName, resume, getResult
2026-01-30 20:11:59 +01:00
Lukas May
acf3b8dae3 feat(04-04): add AgentManager to tRPC context
- Import AgentManager type into context.ts
- Add optional agentManager field to TRPCContext interface
- Add optional agentManager to CreateContextOptions
- Update TrpcAdapterOptions with optional agentManager
- Pass agentManager through to createContext in adapter
2026-01-30 20:11:01 +01:00
Lukas May
f0db74cf8c docs(04-03): complete ClaudeAgentManager adapter plan
Tasks completed: 2/2
- Implement ClaudeAgentManager adapter
- Write tests for AgentManager

SUMMARY: .planning/phases/04-agent-lifecycle/04-03-SUMMARY.md
2026-01-30 20:08:55 +01:00
Lukas May
b718d59cbf test(04-03): add comprehensive tests for ClaudeAgentManager
- Test spawn with worktree and agent record creation
- Test duplicate name rejection
- Test AgentSpawned event emission
- Test stop with subprocess kill and status update
- Test list, get, getByName operations
- Test resume with session_id and --resume flag
- Test AgentResumed event emission
- Fix: use agent.id from repository for activeAgents tracking
2026-01-30 20:07:28 +01:00
Lukas May
81934237ca feat(04-03): implement ClaudeAgentManager adapter
- Use Claude CLI with --output-format json for agent spawning
- Extract session_id from JSON result for resume capability
- Emit lifecycle events: spawned, stopped, crashed, resumed, waiting
- Handle waiting_for_input status for AskUserQuestion pauses
- Uses WorktreeManager for isolated agent workspaces
2026-01-30 20:05:03 +01:00
Lukas May
9ab6e5eb28 docs(04-01): complete agent schema & repository plan
Tasks completed: 3/3
- Add agents table to database schema
- Create AgentRepository port interface
- Create DrizzleAgentRepository adapter with tests

SUMMARY: .planning/phases/04-agent-lifecycle/04-01-SUMMARY.md
2026-01-30 20:02:42 +01:00
Lukas May
53259afb07 docs(04-02): complete AgentManager port & events plan
Tasks completed: 2/2
- Define AgentManager port interface and domain types
- Add agent lifecycle events to events module

SUMMARY: .planning/phases/04-agent-lifecycle/04-02-SUMMARY.md
2026-01-30 20:01:35 +01:00
Lukas May
25f98fcbe1 feat(04-01): create DrizzleAgentRepository adapter with tests
- Implement DrizzleAgentRepository with all AgentRepository methods
- Add findByName, findByTaskId, findBySessionId lookups
- Add findByStatus for filtering including waiting_for_input
- Add updateStatus and updateSessionId for state changes
- Add agents table to test-helpers.ts SQL
- Export DrizzleAgentRepository from drizzle/index.ts
- 22 tests covering all operations and edge cases
2026-01-30 20:01:00 +01:00
Lukas May
ddc6f3b4e7 feat(04-02): add agent lifecycle events to events module
- AgentSpawnedEvent for new agent creation
- AgentStoppedEvent with reason (user_requested, task_complete, error, waiting_for_input)
- AgentCrashedEvent for unexpected failures
- AgentResumedEvent for session resumption
- AgentWaitingEvent when agent pauses on AskUserQuestion
- Updated DomainEventMap union with all agent events
2026-01-30 19:59:37 +01:00
Lukas May
eec5f1398e feat(04-01): create AgentRepository port interface
- Define AgentRepository interface with CRUD operations
- Add findByName, findByTaskId, findBySessionId for lookups
- Add findByStatus for filtering by agent state
- Add updateStatus and updateSessionId for state changes
- Export AgentStatus type
- Export from repositories barrel file
2026-01-30 19:59:04 +01:00
Lukas May
88889700c2 feat(04-02): define AgentManager port interface and domain types
- AgentStatus type for agent lifecycle states
- SpawnAgentOptions for spawn configuration
- AgentInfo for agent state representation
- AgentResult for execution results
- AgentManager interface with spawn, stop, list, get, getByName, resume, getResult
2026-01-30 19:58:55 +01:00
Lukas May
dfaa51076b feat(04-01): add agents table to database schema
- Define agents table with id, name (unique), taskId, sessionId, worktreeId, status
- Status enum: idle, running, waiting_for_input, stopped, crashed
- Foreign key to tasks with onDelete: 'set null' (agent may outlive task)
- Add agentsRelations linking to tasks
- Export Agent and NewAgent types
2026-01-30 19:58:35 +01:00
Lukas May
ffe5acceff docs(04): update agent plans with names and CLI approach
Key changes:
- Add agent names (human-readable like 'gastown') instead of UUID-only
- Use Claude CLI with --output-format json instead of SDK streaming
- Session ID extracted from CLI JSON output, not SDK init message
- Add waiting_for_input status for AskUserQuestion scenarios
- Resume flow is for answering agent questions, not general resumption
- CLI commands use names as primary identifier
2026-01-30 19:53:29 +01:00
Lukas May
781fbd0b23 docs(04): create agent lifecycle phase plan
Phase 04: Agent Lifecycle
- 4 plans in 3 waves
- Wave 1 (parallel): 04-01 schema/repository, 04-02 port/events
- Wave 2: 04-03 ClaudeAgentManager adapter (Claude Agent SDK)
- Wave 3: 04-04 tRPC + CLI integration

Requirements covered:
- AGENT-01: Spawn new agent with task assignment
- AGENT-02: Stop running agent
- AGENT-03: List all agents with status
- AGENT-04: Session persistence via SDK session IDs
- AGENT-05: Background mode via Node.js event loop
- AGENT-07: JSON output via Claude Agent SDK
2026-01-30 19:43:28 +01:00
Lukas May
e19b14944c docs(03): complete git-integration phase 2026-01-30 19:33:22 +01:00
Lukas May
1a9df73139 docs(03-02): complete WorktreeManager adapter plan
Tasks completed: 3/3
- Install simple-git and create WorktreeManager adapter with CRUD
- Implement diff and merge operations (merged with Task 1)
- Write tests for WorktreeManager (23 tests)

SUMMARY: .planning/phases/03-git-integration/03-02-SUMMARY.md
2026-01-30 19:32:22 +01:00
Lukas May
c32bc553d0 test(03-02): add comprehensive tests for WorktreeManager adapter
- 23 tests covering all WorktreeManager operations
- Test setup creates temp git repos with initial commit
- CRUD tests: create, remove, list, get operations
- Diff tests: clean worktree, added/modified/deleted files
- Merge tests: clean merge, conflict detection, abort/cleanup
- Event emission tests for all 4 worktree events
- Edge case tests: no eventBus, uncommitted changes on remove
2026-01-30 19:30:30 +01:00
Lukas May
0cf2849993 feat(03-02): install simple-git and create WorktreeManager adapter with CRUD
- Install simple-git dependency for git operations
- Create SimpleGitWorktreeManager class implementing WorktreeManager port
- Implement create(), remove(), list(), get() methods
- EventBus optional dependency injection for emitting worktree events
- Worktrees stored in .cw-worktrees directory
2026-01-30 19:27:35 +01:00
Lukas May
b70c07caf2 docs(03-01): complete git events and worktree port plan
Tasks completed: 2/2
- Add git domain events to event types
- Create WorktreeManager port interface

SUMMARY: .planning/phases/03-git-integration/03-01-SUMMARY.md
2026-01-30 19:25:21 +01:00
Lukas May
99e44425a3 feat(03-01): create WorktreeManager port interface
- Worktree type for representing git worktrees
- WorktreeDiff type for change preview
- MergeResult type for merge operation results
- WorktreeManager interface (PORT) with CRUD, diff, and merge methods
- Full JSDoc documentation explaining port-adapter relationship

Covers requirements: GIT-01, GIT-02, GIT-03, GIT-04
2026-01-30 19:23:59 +01:00
Lukas May
9d7b90b238 feat(03-01): add git domain events to event system
- WorktreeCreatedEvent for worktree creation tracking
- WorktreeRemovedEvent for worktree cleanup tracking
- WorktreeMergedEvent for successful merge tracking
- WorktreeConflictEvent for merge conflict notification
- All events added to DomainEventMap union type
2026-01-30 19:23:06 +01:00