Files
Codewalkers/.planning/phases/01-core-infrastructure/01-04-PLAN.md
Lukas May 074f79b855 docs(01): create phase 1 plan
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
2026-01-30 13:06:38 +01:00

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
01-01
src/logging/types.ts
src/logging/writer.ts
src/logging/manager.ts
src/logging/index.ts
true
Create file-based logging infrastructure for per-process stdout/stderr capture.

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>

@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md Task 1: Create log directory management src/logging/types.ts, src/logging/manager.ts Create src/logging/types.ts: - LogLevel: 'debug' | 'info' | 'warn' | 'error' - LogEntry: { timestamp: Date, level: LogLevel, processId: string, message: string } - LogConfig: { baseDir: string, maxFileSize?: number, retainDays?: number }
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>
After completion, create `.planning/phases/01-core-infrastructure/01-04-SUMMARY.md`