Files
Codewalkers/.planning/phases/01.1-hexagonal-architecture/01.1-06-PLAN.md
Lukas May 5c5632dccf docs(01.1): create phase plan
Phase 01.1: Hexagonal Architecture
- 6 plans in 3 waves
- Wave 1: Event bus + tRPC foundation (parallel)
- Wave 2: Process, logging, server module refactors (parallel)
- Wave 3: CLI tRPC integration
- Ready for execution
2026-01-30 13:49:07 +01:00

4.2 KiB

phase, plan, type, wave, depends_on, files_modified, autonomous
phase plan type wave depends_on files_modified autonomous
01.1-hexagonal-architecture 06 execute 3
01.1-02
01.1-05
src/cli/trpc-client.ts
src/cli/index.ts
src/server/trpc-adapter.ts
src/server/index.ts
tests/integration/cli-server.test.ts
true
Integrate tRPC client into CLI and add HTTP adapter to server.

Purpose: Complete the tRPC contract by connecting CLI to server. This establishes the pattern for all future client-server communication. Output: CLI communicates with server via tRPC, with integration tests proving the full flow.

<execution_context> @/.claude/get-shit-done/workflows/execute-plan.md @/.claude/get-shit-done/templates/summary.md </execution_context>

@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/01.1-hexagonal-architecture/01.1-02-SUMMARY.md @.planning/phases/01.1-hexagonal-architecture/01.1-05-SUMMARY.md

@src/cli/index.ts @src/server/index.ts @src/trpc/index.ts

Task 1: Add tRPC HTTP adapter to server and create CLI client src/server/trpc-adapter.ts, src/server/index.ts, src/cli/trpc-client.ts, package.json Install additional dependency if needed: - npm install @trpc/client (should already be dev dep, move to regular deps)
Create src/server/trpc-adapter.ts:
- Create function to handle tRPC requests via node:http
- Use @trpc/server/adapters/fetch or manual handling
- Route /trpc/* requests to tRPC router
- Create context with eventBus, serverStartedAt, processCount

Modify CoordinationServer:
- In handleRequest(), add routing for /trpc/* paths
- Delegate to tRPC adapter
- Keep existing /health and /status routes for backwards compatibility
- tRPC endpoints: /trpc/health, /trpc/status

Create src/cli/trpc-client.ts:
- Create tRPC client using @trpc/client
- Configure with httpBatchLink pointing to http://127.0.0.1:{port}/trpc
- Export typed client
- Export helper function: createTrpcClient(port: number)

Key: The existing HTTP endpoints (/health, /status) remain for curl/debugging.
CLI will use tRPC endpoints for type safety.
npm run build succeeds tRPC adapter integrated into server, CLI client created Task 2: Update CLI status command and write integration tests src/cli/index.ts, tests/integration/cli-server.test.ts Update src/cli/index.ts: - Modify status command to use tRPC client instead of placeholder - Create tRPC client with default port (3847) or env var - Call health procedure and display result - Handle connection errors gracefully (server not running)
Keep the placeholder message if tRPC call fails:
```
Server not running or unreachable. Start with: cw --server
```

Create tests/integration/cli-server.test.ts:
- Test full flow: start server, call tRPC from client, verify response
- Test health procedure returns correct data
- Test status procedure returns correct data
- Test client handles server not running

Integration test approach:
- Start CoordinationServer on random port in beforeAll
- Create tRPC client pointing to that port
- Run procedures, verify responses
- Stop server in afterAll

These are INTEGRATION tests, not unit tests - they test the full stack.
npm test passes with all tests including integration tests CLI uses tRPC for status, integration tests prove full flow works Before declaring plan complete: - [ ] npm run build succeeds - [ ] npm test passes (all tests including integration) - [ ] cw status connects to server via tRPC - [ ] tRPC endpoints work alongside HTTP endpoints - [ ] Full flow tested: server start → tRPC call → response

<success_criteria>

  • All tasks completed
  • All verification checks pass
  • CLI communicates with server via type-safe tRPC
  • Integration tests prove the architecture works end-to-end </success_criteria>
After completion, create `.planning/phases/01.1-hexagonal-architecture/01.1-06-SUMMARY.md`