Phase 01: Core Infrastructure - 5 plans in 3 waves - Wave 1: Project foundation (01-01) - Wave 2: CLI, process mgmt, logging (01-02, 01-03, 01-04) [parallel] - Wave 3: Server mode & shutdown (01-05) - Ready for execution
3.7 KiB
3.7 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous
| phase | plan | type | wave | depends_on | files_modified | autonomous | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-core-infrastructure | 04 | execute | 2 |
|
|
true |
Purpose: Each agent process needs its own log files. This creates the logging infrastructure that agent processes will use. Output: LogManager that creates and manages per-process log files in a dedicated directory.
<execution_context>
@/.claude/get-shit-done/workflows/execute-plan.md
@/.claude/get-shit-done/templates/summary.md
</execution_context>
Create src/logging/manager.ts:
- LogManager class:
- constructor(config: LogConfig) - baseDir defaults to ~/.cw/logs
- ensureLogDir(): Promise<void> - creates log directory if not exists
- getLogPath(processId: string, stream: 'stdout' | 'stderr'): string
- cleanOldLogs(retainDays: number): Promise<number> - removes logs older than N days
- listLogs(): Promise<string[]> - lists all log files
Use node:fs/promises for all file operations.
Use node:path and node:os for cross-platform paths.
Log directory structure: ~/.cw/logs/{processId}/stdout.log, stderr.log
LogManager creates ~/.cw/logs directory, returns correct paths
Log directory management works, paths are cross-platform correct
Task 2: Create per-process log writer
src/logging/writer.ts, src/logging/index.ts
Create src/logging/writer.ts:
- ProcessLogWriter class:
- constructor(processId: string, logManager: LogManager)
- open(): Promise - opens file handles for stdout/stderr
- writeStdout(data: string | Buffer): Promise
- writeStderr(data: string | Buffer): Promise
- close(): Promise - flushes and closes file handles
- getStdoutStream(): fs.WriteStream
- getStderrStream(): fs.WriteStream
Use fs.createWriteStream with { flags: 'a' } for append mode.
Add timestamps to each line of output.
Handle backpressure properly (pause source if drain needed).
Create src/logging/index.ts:
- Export LogManager, ProcessLogWriter, types
- Export createLogger(processId: string) convenience function
ProcessLogWriter creates files, writes stdout/stderr with timestamps
Per-process logging captures output to separate files with timestamps
Before declaring plan complete:
- [ ] `npm run build` succeeds
- [ ] LogManager creates ~/.cw/logs/ directory
- [ ] ProcessLogWriter creates per-process log files
- [ ] Stdout and stderr go to separate files
- [ ] Log entries include timestamps
- [ ] File handles close properly (no resource leaks)
<success_criteria>
- All tasks completed
- All verification checks pass
- Logging infrastructure ready for agent process output capture
- Satisfies INFRA-05 (basic logging captures stdout/stderr per agent) </success_criteria>