context-mode icon indicating copy to clipboard operation
context-mode copied to clipboard

Hook bundle footprint: ~500 KB of JS shipped per install

Open ofrik opened this issue 6 months ago • 0 comments

Each install writes 20+ .mjs files plus 5 pre-built .bundle.mjs files to the platform config directory. The bundles (session-db.bundle.mjs, security.bundle.mjs, session-snapshot.bundle.mjs, etc.) are generated by esbuild and collectively add ~500 KB of JavaScript to the user's home directory per platform.

Suggested fix: Move all hook business logic into CLI subcommands exposed by the main context-mode binary. Hook .mjs files become thin shims (<50 lines each) that call context-mode session event-add, context-mode session snapshot-build, etc. via child_process.execSync. Total JS on disk drops to <5 KB.

Benefits:

  • Single source of truth (no JS bundle to keep in sync with server logic)
  • No esbuild step needed for hooks
  • Hook updates ship with the binary, not as separate files
  • Easier to audit (thin shims are fully readable)

ofrik avatar May 23 '26 00:05 ofrik