Skip to content

refactor: hook infrastructure DRY cleanup (debug bootstrap + log init helpers) #229

@dean0x

Description

@dean0x

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

  1. 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
  2. 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
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    qualityCode quality improvementstech-debtTechnical debt items to address

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions