|
| 1 | +## Plan: Refactor Logger to Pass as Parameter |
| 2 | + |
| 3 | +### Step 1: Search for logger imports |
| 4 | +- Use `code_search` with pattern `import \{ logger` (escape curly braces) |
| 5 | +- Set `cwd: "backend"` to limit search scope |
| 6 | +- Exclude websocket-action.ts files |
| 7 | + |
| 8 | +### Step 2: For each file (except websocket-action.ts) |
| 9 | +- Remove the `import { logger }` line |
| 10 | +- Refactor function signature to use single `params` object containing all arguments including `logger: Logger` |
| 11 | +- Import proper type: `import type { Logger } from '@codebuff/types/logger'` |
| 12 | + - Don't manually type as `{ debug: Function; ... }` - will fail typecheck |
| 13 | +- Add destructuring at top of function body to extract params |
| 14 | + |
| 15 | +### Step 3: Update all callers |
| 16 | +- **Always run full `bun run typecheck`** (not head/tail!) to find ALL errors |
| 17 | +- Update function calls to pass object with named properties |
| 18 | +- For tests: create mock logger constant with all 5 methods (debug, info, warn, error, fatal) |
| 19 | +- Use `allowMultiple: true` in str_replace when updating multiple calls in same file |
| 20 | +- **Check carefully** - there may be multiple call sites in the same file! |
| 21 | +- Repeat typecheck until ALL errors resolved |
| 22 | + |
| 23 | +### Step 4: Commit changes |
| 24 | +- **Do NOT use git-committer agent** - it's too slow |
| 25 | +- Instead, manually run: `git add <files>` then `git commit -m "<message>"` |
| 26 | +- Keep commit message concise but descriptive |
| 27 | +- Include Codebuff footer in commit message |
0 commit comments