What
Architecture-audit nightly sweep flagged seven source files that exceed the structural size thresholds (700 lines for general source, 1000 for src/main.ts). Files this large tend to mix multiple responsibilities, make code review harder, and complicate diffs when small changes ripple across many concerns.
Evidence
Line counts as of master:
src/main.ts — 1046 lines (threshold 1000)
src/services/hook-manager.ts — 958 lines
src/ui/agent-view/agent-view-messages.ts — 931 lines
src/services/scheduled-task-manager.ts — 919 lines
src/ui/agent-view/agent-view.ts — 904 lines
src/ui/agent-view/agent-view-ui.ts — 894 lines
src/ui/hook-management-modal.ts — 703 lines
Proposed unit of work
Each file is its own discrete unit of work — don't bundle. Suggested split strategies (to be confirmed during design):
src/main.ts — keep the ObsidianGemini plugin class as the lifecycle entry point; extract the command-registration block to a new src/commands/register-commands.ts, and any inline ribbon/settings hooks that don't belong in lifecycle.
src/services/hook-manager.ts — split into hook-manager.ts (registry + dispatch) and hook-runner.ts already exists; consider whether matcher/condition evaluation can move into its own hook-matcher.ts.
src/ui/agent-view/agent-view-messages.ts — message rendering already has helpers in agent-view-tool-display.ts; consider extracting the tool-section parser (the Tool Execution Results: block detection) into a separate tool-section-parser.ts.
src/services/scheduled-task-manager.ts — schedule parsing, missed-run detection, and execution dispatch could each live in their own module under src/services/scheduled-tasks/.
src/ui/agent-view/agent-view.ts + agent-view-ui.ts — already broken up by concern (-messages, -send, -tools, -tool-display, etc.); audit which methods on the view class could move into one of the existing helpers, or warrant a new agent-view-projects.ts / agent-view-attachments.ts (if not already present).
src/ui/hook-management-modal.ts — only 3 lines over threshold; lowest-priority split, may not be worth the diff.
File one sub-issue per file when picking up; this issue is a tracker, not a single PR target.
Out of scope
- Behavior changes. Each split should be a pure code-motion refactor with full test coverage maintained.
- Renames of public surface (anything in
src/index.ts). Splits should preserve external imports via re-exports if needed.
- Changing the file-size threshold itself. If you disagree with 700 lines, file a separate discussion issue.
Filed by the architecture-audit skill. If this isn't worth doing, close with wontfix — the skill checks closed-with-wontfix and won't refile.
What
Architecture-audit nightly sweep flagged seven source files that exceed the structural size thresholds (700 lines for general source, 1000 for
src/main.ts). Files this large tend to mix multiple responsibilities, make code review harder, and complicate diffs when small changes ripple across many concerns.Evidence
Line counts as of master:
src/main.ts— 1046 lines (threshold 1000)src/services/hook-manager.ts— 958 linessrc/ui/agent-view/agent-view-messages.ts— 931 linessrc/services/scheduled-task-manager.ts— 919 linessrc/ui/agent-view/agent-view.ts— 904 linessrc/ui/agent-view/agent-view-ui.ts— 894 linessrc/ui/hook-management-modal.ts— 703 linesProposed unit of work
Each file is its own discrete unit of work — don't bundle. Suggested split strategies (to be confirmed during design):
src/main.ts— keep theObsidianGeminiplugin class as the lifecycle entry point; extract the command-registration block to a newsrc/commands/register-commands.ts, and any inline ribbon/settings hooks that don't belong in lifecycle.src/services/hook-manager.ts— split intohook-manager.ts(registry + dispatch) andhook-runner.tsalready exists; consider whether matcher/condition evaluation can move into its ownhook-matcher.ts.src/ui/agent-view/agent-view-messages.ts— message rendering already has helpers inagent-view-tool-display.ts; consider extracting the tool-section parser (theTool Execution Results:block detection) into a separatetool-section-parser.ts.src/services/scheduled-task-manager.ts— schedule parsing, missed-run detection, and execution dispatch could each live in their own module undersrc/services/scheduled-tasks/.src/ui/agent-view/agent-view.ts+agent-view-ui.ts— already broken up by concern (-messages,-send,-tools,-tool-display, etc.); audit which methods on the view class could move into one of the existing helpers, or warrant a newagent-view-projects.ts/agent-view-attachments.ts(if not already present).src/ui/hook-management-modal.ts— only 3 lines over threshold; lowest-priority split, may not be worth the diff.File one sub-issue per file when picking up; this issue is a tracker, not a single PR target.
Out of scope
src/index.ts). Splits should preserve external imports via re-exports if needed.Filed by the
architecture-auditskill. If this isn't worth doing, close withwontfix— the skill checks closed-with-wontfix and won't refile.