---
phase: 01-core-infrastructure
plan: 03
type: execute
wave: 2
depends_on: ["01-01"]
files_modified: [src/process/registry.ts, src/process/manager.ts, src/process/types.ts]
autonomous: true
---
Create process management utilities for spawning, tracking, and stopping child processes.
Purpose: Infrastructure for managing agent processes in later phases. Agents are child processes that need lifecycle management.
Output: ProcessManager class with spawn, stop, list, and restart operations.
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
Task 1: Create process types and registry
src/process/types.ts, src/process/registry.ts
Create src/process/types.ts:
- ProcessInfo interface: { id: string, pid: number, command: string, args: string[], startedAt: Date, status: 'running' | 'stopped' | 'crashed' }
- SpawnOptions: { id: string, command: string, args?: string[], cwd?: string, env?: Record }
Create src/process/registry.ts:
- ProcessRegistry class with Map storage
- register(info: ProcessInfo): void
- unregister(id: string): void
- get(id: string): ProcessInfo | undefined
- getAll(): ProcessInfo[]
- getByPid(pid: number): ProcessInfo | undefined
- clear(): void
Registry is in-memory for now (Phase 2 adds SQLite persistence).
TypeScript compiles, registry can add/remove/list processes
ProcessRegistry class works with full CRUD operations
Task 2: Create process manager with spawn/stop
src/process/manager.ts, src/process/index.ts
Create src/process/manager.ts:
- Import execa for process spawning
- ProcessManager class:
- constructor takes ProcessRegistry instance
- spawn(options: SpawnOptions): Promise - spawns detached child, registers in registry, returns info
- stop(id: string): Promise - sends SIGTERM, waits up to 5s, then SIGKILL if needed
- stopAll(): Promise - stops all registered processes
- restart(id: string): Promise - stops then respawns with same config
- isRunning(id: string): boolean - checks if process is alive
Use execa with { detached: true } for background processes.
Store spawned process reference to enable stop/restart.
Handle process exit events to update registry status.
Create src/process/index.ts - export ProcessManager, ProcessRegistry, types.
Can spawn a simple process (e.g., sleep 10), list it, stop it
ProcessManager can spawn, stop, restart, and list child processes
Before declaring plan complete:
- [ ] `npm run build` succeeds
- [ ] ProcessRegistry correctly tracks process info
- [ ] ProcessManager.spawn() starts a detached process
- [ ] ProcessManager.stop() terminates running process
- [ ] ProcessManager.isRunning() correctly reports status
- [ ] Process exit updates registry status automatically
- All tasks completed
- All verification checks pass
- Process lifecycle (spawn → track → stop) works end-to-end
- Infrastructure ready for agent management in Phase 4