Overview
Three related boilerplate patterns in hook scripts block smooth hook maintenance and create tight coupling. This issue consolidates tech debt from PR #228.
Items
-
Debug boilerplate (4 lines, 7 hooks)
- Repeated across: sidecar-capture, sidecar-dispatch, sidecar-evaluate, session-start-context, session-start-memory, pre-compact-memory, preamble
- Risk: any debug protocol change requires editing 7 files
- Solution: extract to
devflow_debug_bootstrap helper
-
log() function definition (4 lines, 5 hooks)
- Repeated across: sidecar-capture, sidecar-dispatch, sidecar-evaluate, session-start-context, session-start-memory
- Risk: logging API inconsistencies, maintenance burden
- Solution: extract to
devflow_log_init helper
-
Dual logging system message overlap (design concern)
dbg() (debug-toggle) and log() (always-on) both write to logs
- Deliberate by design but worth revisiting in follow-up
Implementation Plan
- Move 4-line debug init sequence to
scripts/hooks/lib/debug-bootstrap.cjs
- Move 4-line log function definition to
scripts/hooks/lib/log-init.cjs
- Update 7 hooks to source debug-bootstrap
- Update 5 hooks to source log-init
- Test all hooks with DEVFLOW_HOOK_DEBUG on/off
References
Overview
Three related boilerplate patterns in hook scripts block smooth hook maintenance and create tight coupling. This issue consolidates tech debt from PR #228.
Items
Debug boilerplate (4 lines, 7 hooks)
devflow_debug_bootstraphelperlog() function definition (4 lines, 5 hooks)
devflow_log_inithelperDual logging system message overlap (design concern)
dbg()(debug-toggle) andlog()(always-on) both write to logsImplementation Plan
scripts/hooks/lib/debug-bootstrap.cjsscripts/hooks/lib/log-init.cjsReferences