Skip to content

refactor(structure): split pure parsers into obsidian-markdown/ and MCP wiring into mcp-core/#168

Merged
aliasunder merged 1 commit into
mainfrom
claude/vault-bootstrap-setup-lk9df4
Jun 22, 2026
Merged

refactor(structure): split pure parsers into obsidian-markdown/ and MCP wiring into mcp-core/#168
aliasunder merged 1 commit into
mainfrom
claude/vault-bootstrap-setup-lk9df4

Conversation

@aliasunder

@aliasunder aliasunder commented Jun 22, 2026

Copy link
Copy Markdown
Owner

What

Makes the parser / vault-IO / protocol layering physical, with zero behavior change — pure git mv plus import-specifier rewrites.

  • src/vault-mcp/obsidian-markdown/ (new) — the pure Obsidian/Markdown parsers, none of which touch the filesystem: frontmatter, callouts (was callout-parser), headings (was heading-parser), and links (promoted from the vault-mcp/ root).
  • src/vault-mcp/mcp-core/ (new) — the MCP protocol surface: mcp-router, tool-definitions, prompt-definitions.
  • vault-operations/ keeps the filesystem I/O + use-cases (vault-filesystem, vault-patcher, note-mover, memory-store, daily-notes).

Top-level rule going forward: folders are domains; the only loose files are the entry point (server.ts) and its config.ts.

Why

The pure parsers were already pure (no fs imports) but scattered — some buried under vault-operations/, links.ts loose at the root — and search-index.ts reached into vault-operations/ just to grab a pure parser (a backwards dependency). This isolates the parsing layer so both the indexer and vault-operations consume it as a shared peer — the same treatment links.ts got in #165.

Scope

Structure only — no logic, no new modules. Deliberate follow-ups (a new lines.ts consolidating the currently-duplicated fence state machines, memory parseSections → the shared headings parser, and utils/ extraction of describeError + the ENOENT fs helpers) land in separate PRs.

Notes

  • Tests move with their sources (co-located __tests__/); the two renamed parsers' tests are renamed to match.
  • No config changes — every build/test tool globs src/**.
  • AGENTS.md structure tree + two stale comment cross-references to the renamed files updated.

Verification

  • npm run build (tsc, server + cli) ✅
  • npm test898 passed
  • npm run lint
  • git diff confirms renames + import lines only; no function bodies touched.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Reorganized codebase to consolidate Markdown and Obsidian parsing utilities into a dedicated module, improving code organization and maintainability.

…CP wiring into mcp-core/

Make the parser/IO layering physical with zero behavior change. Pure
git mv + import-specifier rewrites:

- Pure Obsidian/Markdown parsers -> src/vault-mcp/obsidian-markdown/
  (frontmatter, callouts [was callout-parser], headings [was
  heading-parser], links). No fs/db/MCP deps.
- MCP protocol surface -> src/vault-mcp/mcp-core/
  (mcp-router, tool-definitions, prompt-definitions).
- Tests move with their sources (co-located __tests__/).
- Top-level rule: folders are domains; only the entry point (server.ts)
  and its config.ts stay loose.

Also updates the AGENTS.md structure tree and two stale comment
cross-references to the renamed files. No config changes needed (all
build/test tooling uses src/** globs). 898 tests pass, build + lint green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

@aliasunder

Copy link
Copy Markdown
Owner Author

/@CodeRabbit

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

@aliasunder Sure, I'll review the changes in this PR!

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 81ffa203-d8ae-4d53-b752-6a3e2c62fa06

📥 Commits

Reviewing files that changed from the base of the PR and between fcf0fc6 and d288783.

📒 Files selected for processing (22)
  • AGENTS.md
  • src/vault-mcp/mcp-core/__tests__/mcp-router.test.ts
  • src/vault-mcp/mcp-core/__tests__/prompt-definitions.test.ts
  • src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts
  • src/vault-mcp/mcp-core/mcp-router.ts
  • src/vault-mcp/mcp-core/prompt-definitions.ts
  • src/vault-mcp/mcp-core/tool-definitions.ts
  • src/vault-mcp/obsidian-markdown/__tests__/callouts.test.ts
  • src/vault-mcp/obsidian-markdown/__tests__/headings.test.ts
  • src/vault-mcp/obsidian-markdown/__tests__/links.test.ts
  • src/vault-mcp/obsidian-markdown/callouts.ts
  • src/vault-mcp/obsidian-markdown/frontmatter.ts
  • src/vault-mcp/obsidian-markdown/headings.ts
  • src/vault-mcp/obsidian-markdown/links.ts
  • src/vault-mcp/search/search-index.ts
  • src/vault-mcp/server.ts
  • src/vault-mcp/vault-operations/__tests__/memory-store.test.ts
  • src/vault-mcp/vault-operations/__tests__/vault-filesystem.test.ts
  • src/vault-mcp/vault-operations/memory-store.ts
  • src/vault-mcp/vault-operations/note-mover.ts
  • src/vault-mcp/vault-operations/vault-filesystem.ts
  • src/vault-mcp/vault-operations/vault-patcher.ts

📝 Walkthrough

Walkthrough

A new obsidian-markdown/ module is established as the shared home for Obsidian/Markdown parsing utilities (frontmatter, callouts, headings, links). All consuming modules in vault-operations/, search/, mcp-core/, and server.ts have their import paths updated to reference the new module location. No logic changes are made anywhere.

Changes

obsidian-markdown module extraction and import rewiring

Layer / File(s) Summary
New obsidian-markdown module documentation and internal references
AGENTS.md, src/vault-mcp/obsidian-markdown/callouts.ts, src/vault-mcp/obsidian-markdown/__tests__/callouts.test.ts, src/vault-mcp/obsidian-markdown/__tests__/headings.test.ts
AGENTS.md structure listing is updated to document the new obsidian-markdown/ directory. Comment reference in callouts.ts and test import paths in callouts.test.ts and headings.test.ts are updated to match the renamed module files.
vault-operations rewired to obsidian-markdown
src/vault-mcp/vault-operations/memory-store.ts, src/vault-mcp/vault-operations/note-mover.ts, src/vault-mcp/vault-operations/vault-filesystem.ts, src/vault-mcp/vault-operations/vault-patcher.ts, src/vault-mcp/vault-operations/__tests__/memory-store.test.ts, src/vault-mcp/vault-operations/__tests__/vault-filesystem.test.ts
memory-store.ts, note-mover.ts, vault-filesystem.ts, and vault-patcher.ts replace local ./frontmatter.js, ./callout-parser.js, ./heading-parser.js, and ../links.js imports with ../obsidian-markdown/* equivalents. Corresponding test files update parseNote import source.
search-index and server.ts rewired
src/vault-mcp/search/search-index.ts, src/vault-mcp/server.ts
search-index.ts replaces frontmatter, callout, and link import sources with ../obsidian-markdown/* modules. server.ts updates createMcpRouter import from ./mcp-router.js to ./mcp-core/mcp-router.js.
mcp-core rewired to correct relative paths
src/vault-mcp/mcp-core/mcp-router.ts, src/vault-mcp/mcp-core/prompt-definitions.ts, src/vault-mcp/mcp-core/tool-definitions.ts, src/vault-mcp/mcp-core/__tests__/mcp-router.test.ts, src/vault-mcp/mcp-core/__tests__/prompt-definitions.test.ts, src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts
mcp-router.ts, prompt-definitions.ts, and tool-definitions.ts update relative import paths for SearchIndex, VaultConfig, Logger, and vault-operations modules to reflect the mcp-core/ subdirectory nesting. All three test files update loadConfig, McpServer, SearchIndex, and logger import paths accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • aliasunder/vault-cortex#130: Introduces parseHeadings/findHeading in vault-operations/heading-parser.ts, which this PR moves to obsidian-markdown/headings.ts and rewires across vault-filesystem and vault-patcher.
  • aliasunder/vault-cortex#160: Introduces vault_move_note in note-mover.ts, whose parsing and link-rewrite dependencies are rewired to obsidian-markdown/* in this PR.
  • aliasunder/vault-cortex#165: Extracts links logic into src/vault-mcp/links.ts and wires it into search-index.ts and note-mover.ts; this PR subsequently moves those same imports to obsidian-markdown/links.js.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main structural refactoring: splitting pure parsers into obsidian-markdown/ and MCP wiring into mcp-core/, which accurately reflects the core changes across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/vault-bootstrap-setup-lk9df4

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@aliasunder
aliasunder merged commit ac53c62 into main Jun 22, 2026
15 checks passed
@aliasunder
aliasunder deleted the claude/vault-bootstrap-setup-lk9df4 branch June 22, 2026 03:11
aliasunder added a commit that referenced this pull request Jun 22, 2026
…ort conventions (#172)

## What

Capstone to the parser/IO restructure (#168, #169, #171). Adds a
**Module layering** section to `AGENTS.md` so the structure those PRs
built is durable and enforceable — recorded as rules, not just implied
by the file tree. Also lands the structure-polish follow-ups (folder
rename + boundary clarifications) agreed during review.

It documents:

- **What each folder is for** (`obsidian-markdown/` ·
`vault-operations/` · `mcp-core/` · `search/` · `oauth/` · `utils/`),
and that a module's folder follows **what it depends on**, not just its
topic.
- **Dependency direction** — `obsidian-markdown/` and `utils/` are
leaves; `vault-operations/` and `search/` build on them; `mcp-core/` and
the wiring depend on everything — plus the "top level is wiring only"
rule.
- **The `vault-filesystem.ts` ↔ `utils/fs.ts` boundary** — **policy vs.
adapter**: `utils/fs.ts` holds only policy-free `node:fs` wrappers,
while the atomic-write strategy, path-safety, and the `vaultFs` data API
stay in `vault-filesystem.ts`. "Mechanically generic" isn't enough to
demote load-bearing vault-I/O policy.
- **`utils/` admission** — generic with zero domain knowledge, clearing
one of two bars: it consolidates real duplication (multi-consumer), or
it is a self-contained, general-purpose primitive
(`mapWithConcurrency`).
- **Export style by module kind** — service/data-layer modules export a
single namespace object (or a factory-closure when stateful:
`createSearchIndex`/`createMemoryStore`); pure parsers/helpers use named
exports; `links.ts` is the deliberate namespace exception (its `/g`
`lastIndex` footgun).

### Structure polish (also in this PR)

- Renamed `vault-mcp/auth/` → `vault-mcp/oauth/` so it no longer
collides conceptually with the top-level `src/auth.ts` token utilities.

Docs + a folder rename — no behavior change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants