chore: phase 5 cleanup — split main.ts 2594→950, one MemoryVault, dead exports, tests 265→286 (+2390/−1975) #24

Merged
Joel merged 4 commits from agent/ops-ivo-obsidian-cleanup into main 2026-10-20 21:35:56 +00:00
Member

Phase 5 cleanup. Five items, one commit each for items 2–5; item 1 needed no commit. Behaviour is unchanged.

1. Branch hygiene (done via the API, no commit)

  • feat/partner-in-crime and feat/mcp-server were 0 commits ahead of main.
  • build/504f507c (ae8db3d) and build/765b7a64 (9bebab9) were each 1 commit ahead. Both were earlier attempts at the state-aware panel. They were superseded by 9505813, which merged as #4.
  • Each head is preserved as the tag archive/<branch>. All four branches are deleted (HTTP 204), so only main remains. No open PRs referenced them.

2. Shared test fakes: test/stubs/vault.ts (+154/−219)

  • There was one fake for each test file: Vault, TinyVault and FixtureVault (twice), plus 5 copies of AT. These are replaced by a single MemoryVault and a single AT.
  • MemoryVault covers everything the old fakes did:
    • seed files and an mtime option
    • reads, writes and binaryWrites counters, and a refuse set
    • Obsidian's binary contract
    • put() and raw()
  • AT is now 2026-09-04T12:00Z. Two regexes in the render and knap tests spelled out the old date, so they now spell this one. They check the same thing as before.
  • Count: 4 VaultPort fakes + 1 subclass + 5 AT → 1 MemoryVault + 2 thin subclasses (DroppingVault, plus authorship's joelTypes) + 1 AT.

3. Dead exports (+3/−19)

  • knockAcceptable and parentFolder had no references outside their own tests: no import, no string or dynamic lookup, nothing in the README or build scripts. They are deleted along with their assertions.
  • The tests those assertions sat in still check knockProblem and flagFolder, so the test count does not drop.

4. Split main.ts: 2594 → 1045 lines (+2206/−1591)

New modules:

Module Contents
src/feed.ts ChangeFeed
src/link.ts VaultLink
src/modals.ts Knock, Commands and Activity modals
src/view.ts ConnorView, VIEW_TYPE
src/settings.ts ConnorSettings, DEFAULTS, ConnorSettingTab
src/tools.ts TOOLS, VaultTools (the tools/call handlers), obsidianVaultPort
  • ConnorPlugin stays in main.ts.
  • The modules import it as a type only, so there is no import cycle at runtime.
  • A line-by-line comparison of the old main.ts against the new modules differs only in imports and the this.plugin re-homing.
  • The audit listed "4 modals". There are 3 Modal subclasses; the 4th class moved is the ItemView, ConnorView.
  • VaultTools is an extra move beyond the audit's list. Without it, main.ts could not reach ≤1000 lines without gutting comments that explain why.
  • New tests (21), each importing the class it covers:
    • changefeed 3
    • vaultlink 2
    • modals 3
    • view 3
    • settings 4
    • tools 6
  • New stubs in test/stubs:
    • FakeEl in dom.ts
    • a window with localStorage in window.ts
    • a fake plugin, plus an Obsidian vault built on MemoryVault, in plugin.ts
    • the obsidian stub's Modal, ItemView and SettingTab now render into FakeEl, and Setting records its controls

5. Comments: main.ts 1045 → 950 lines (+70/−189)

  • Comment lines: 585 in the original main.ts → 203 now. Across main.ts and its split modules: 586 → 468.
  • Cut: dated history, quotes standing in for rationale, war stories, and a banner describing a past refactor.
  • Kept: every comment that explains why or warns about a pitfall.
  • The esbuild bundle is identical before and after once comments are stripped.
  • The repo has no license or header requirement.

Acceptance

  • main.ts is 950 lines (target ≤1000).
  • Every moved class is imported by at least one test.
  • npm run gate is green: check, verify:build and test. Tests go from 265 → 286, 0 failures. main.js builds.
  • Net change: +2390/−1975 across 27 files.
  • suiteshape.py printed nothing for this TS suite, so it does not support TS yet.

After merging: Joel copies the built main.js into his vault (npm ci && npm run build).

🤖 Generated with Claude Code

Phase 5 cleanup. Five items, one commit each for items 2–5; item 1 needed no commit. Behaviour is unchanged. ## 1. Branch hygiene (done via the API, no commit) - `feat/partner-in-crime` and `feat/mcp-server` were 0 commits ahead of main. - `build/504f507c` (ae8db3d) and `build/765b7a64` (9bebab9) were each 1 commit ahead. Both were earlier attempts at the state-aware panel. They were superseded by 9505813, which merged as #4. - Each head is preserved as the tag `archive/<branch>`. All four branches are deleted (HTTP 204), so only `main` remains. No open PRs referenced them. ## 2. Shared test fakes: `test/stubs/vault.ts` (+154/−219) - There was one fake for each test file: `Vault`, `TinyVault` and `FixtureVault` (twice), plus 5 copies of `AT`. These are replaced by a single `MemoryVault` and a single `AT`. - `MemoryVault` covers everything the old fakes did: - seed files and an mtime option - `reads`, `writes` and `binaryWrites` counters, and a `refuse` set - Obsidian's binary contract - `put()` and `raw()` - `AT` is now 2026-09-04T12:00Z. Two regexes in the render and knap tests spelled out the old date, so they now spell this one. They check the same thing as before. - **Count:** 4 VaultPort fakes + 1 subclass + 5 `AT` → 1 `MemoryVault` + 2 thin subclasses (`DroppingVault`, plus authorship's `joelTypes`) + 1 `AT`. ## 3. Dead exports (+3/−19) - `knockAcceptable` and `parentFolder` had no references outside their own tests: no import, no string or dynamic lookup, nothing in the README or build scripts. They are deleted along with their assertions. - The tests those assertions sat in still check `knockProblem` and `flagFolder`, so the test count does not drop. ## 4. Split main.ts: 2594 → 1045 lines (+2206/−1591) New modules: | Module | Contents | |---|---| | `src/feed.ts` | ChangeFeed | | `src/link.ts` | VaultLink | | `src/modals.ts` | Knock, Commands and Activity modals | | `src/view.ts` | ConnorView, VIEW_TYPE | | `src/settings.ts` | ConnorSettings, DEFAULTS, ConnorSettingTab | | `src/tools.ts` | TOOLS, VaultTools (the tools/call handlers), `obsidianVaultPort` | - `ConnorPlugin` stays in main.ts. - The modules import it as a type only, so there is no import cycle at runtime. - A line-by-line comparison of the old main.ts against the new modules differs only in imports and the `this.plugin` re-homing. - The audit listed "4 modals". There are 3 Modal subclasses; the 4th class moved is the ItemView, ConnorView. - VaultTools is an extra move beyond the audit's list. Without it, main.ts could not reach ≤1000 lines without gutting comments that explain why. - **New tests (21), each importing the class it covers:** - changefeed 3 - vaultlink 2 - modals 3 - view 3 - settings 4 - tools 6 - **New stubs in `test/stubs`:** - `FakeEl` in `dom.ts` - a `window` with localStorage in `window.ts` - a fake plugin, plus an Obsidian vault built on `MemoryVault`, in `plugin.ts` - the obsidian stub's Modal, ItemView and SettingTab now render into `FakeEl`, and `Setting` records its controls ## 5. Comments: main.ts 1045 → 950 lines (+70/−189) - Comment lines: 585 in the original main.ts → 203 now. Across main.ts and its split modules: 586 → 468. - **Cut:** dated history, quotes standing in for rationale, war stories, and a banner describing a past refactor. - **Kept:** every comment that explains why or warns about a pitfall. - The esbuild bundle is identical before and after once comments are stripped. - The repo has no license or header requirement. ## Acceptance - main.ts is **950** lines (target ≤1000). - Every moved class is imported by at least one test. - `npm run gate` is green: check, verify:build and test. Tests go from **265 → 286**, 0 failures. `main.js` builds. - Net change: +2390/−1975 across 27 files. - `suiteshape.py` printed nothing for this TS suite, so it does not support TS yet. **After merging:** Joel copies the built `main.js` into his vault (`npm ci && npm run build`). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Four in-memory VaultPort fakes (Vault, TinyVault, FixtureVault x2) and five
copies of the fixed date AT collapse into test/stubs/vault.ts. MemoryVault is
the superset: seed files + mtime options, reads/writes/binaryWrites counters,
a refuse set, Obsidian's real binary contract, and put()/raw() for edits made
outside a lane. AT is 2026-09-04T12:00Z; the two regexes that spelled the old
render/knap date now spell this one. 265/265 tests unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Neither is referenced outside its own test — no import, no string or
dynamic lookup anywhere in src/, README or the build scripts. Their
assertions go with them; the tests that shared a body with them keep their
knockProblem/flagFolder checks, so the count stays 265.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pure moves, no behaviour change. ChangeFeed → src/feed.ts, VaultLink →
src/link.ts (beside src/lib/feed.ts and src/lib/link.ts), the three modals
→ src/modals.ts, ConnorView + VIEW_TYPE → src/view.ts, ConnorSettings +
DEFAULTS + ConnorSettingTab → src/settings.ts. The tools/call handlers and
TOOLS → src/tools.ts as VaultTools (this.app → this.plugin.app); the
vaultPort adapter becomes obsidianVaultPort(vault). ConnorPlugin stays in
main.ts; the moved modules import it as a type only, so there is no runtime
cycle. A line-multiset diff of old main.ts against the new modules differs
only in imports and those re-homings.

Every moved class now has a test that imports it and drives a real path:
changefeed (3), vaultlink (2), modals (3), view (3), settings (4), tools (6)
— 265 → 286 tests. test/stubs grows FakeEl (dom.ts), a window with
localStorage (window.ts), a fake ConnorPlugin and an Obsidian vault over
MemoryVault (plugin.ts); the obsidian stub's Modal/ItemView/SettingTab
render into FakeEl and Setting records its controls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs: trim history and narration comments, main.ts 1045→950 lines (+70/−189)
All checks were successful
gate / gate (pull_request) Successful in 10s
c0489e43f5
Comment lines across main.ts and the modules split from it: 586 → 468
(main.ts alone: 585 originally → 203). Cut: dated changelog notes, quotes
standing in for rationale, "used to / for a week / burned by" stories, a
banner about a past refactor, and a section intro describing a removed
endpoint. Kept: every comment that says why, names a contract, or warns
about a pitfall (Electron's no-op prompt, the loopback-only bind, the
Origin screen, the self-reload closure, the per-vault port derivation).
Bundled code is byte-identical before and after (esbuild, comments
stripped). No license or header requirement exists in this repo.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Joel approved these changes 2026-10-20 21:35:50 +00:00
Joel merged commit 04acfbe278 into main 2026-10-20 21:35:56 +00:00
Joel deleted branch agent/ops-ivo-obsidian-cleanup 2026-10-20 21:35:56 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ZSDev/obsidian-connor!24
No description provided.