Vyasa Extension Refactor Audit and Execution Plan

Mechanical Migration PlanURL copied

Phase 8: Split Global JavaScript Into Extension AssetsURL copied

Goal:

  • Global JS stops being the feature junk drawer.

Cut order:

  1. Tasks: lines around task constants through openTasksFullscreen.
  1. D2: D2 import and D2 functions.
  1. Mermaid: Mermaid import and Mermaid functions.
  1. Tabs: switchTab, initTabPanelHeights.
  1. Themes: theme debug functions.
  1. Sidebar/layout: sidebar reveal, mobile menus, keyboard shortcuts.
  1. Search: search persistence, command palette if search-owned.
  1. Bookmarks.
  1. Annotations.
  1. Documents: code copy, heading permalink, PDF focus, iframe fullscreen, JSON focus.
  1. Math/code highlight.

Use marker extraction. Example:

awk '/^const vyasaBookmarks/{flag=1} /^function loadSidebarFolderBranch/{flag=0} flag' vyasa/static/scripts.js > vyasa/extensions_builtin/bookmarks/static/bookmarks.js

After each cut:

  • Register a bundle.
  • Request the bundle from renderer/route/layout.
  • Remove the copied section from scripts.js.
  • Run browser smoke test if UI changed.

Acceptance:

  • vyasa/static/scripts.js is under 500 lines or deleted.
  • No extension-specific selectors remain in global JS.