Skip to content

feat: add separate Code Mode for fenced code blocks - #53

Open
TyceHerrman wants to merge 1 commit into
joybro:mainfrom
TyceHerrman:agent/issue-52-code-mode
Open

feat: add separate Code Mode for fenced code blocks#53
TyceHerrman wants to merge 1 commit into
joybro:mainfrom
TyceHerrman:agent/issue-52-code-mode

Conversation

@TyceHerrman

Copy link
Copy Markdown

Summary

Add an optional Code Mode that keeps prose in the existing Notes index and
embeds fenced code blocks in a separate Code index with its own model. Results
remain mode-specific; scores from different embedding spaces are never mixed.
Code Mode is off by default, so existing Notes behavior is unchanged.

  • Extract backtick and tilde fences with language and line metadata.
  • Support independent Code embedding models through local Hugging
    Face/Transformers models with ONNX weights, Ollama, OpenAI-compatible APIs,
    and Google Gemini. Recommended built-ins are all-MiniLM-L6-v2 and
    paraphrase-multilingual-MiniLM-L12-v2; no code-specialized model is bundled.
  • Give Code its own namespaced persistence, status, queues, fingerprints, and
    rebuild lifecycle.
  • Add Notes/Code switching to the sidebar, bottom view, and Semantic Search.
  • Make model and index changes transactional, with rollback and lifecycle gates
    that prevent stale work from publishing results.
  • Document persistence, resource use, mobile constraints, and remote-provider
    privacy implications.

No new runtime dependencies, IndexedDB schema-version bump, release-version
bump, or changes to existing Notes persistence names.

Closes #52.

Test plan

  • npm run test — 36 files, 240 tests
  • npm run lint
  • npm run build
  • git diff --check

Automated coverage includes extraction and chunking, Notes/Code partitioning,
persistence and migration, mode-specific routing and caches, transactional
rollback, stale-result suppression, teardown, and unload behavior.

Manual Obsidian verification

Verified with disposable vaults on Obsidian 1.12.7 and 1.13.1. Build artifacts
were copied manually because install-local delegates to a gitignored,
developer-local helper that is not shipped with the repository.

  • Confirm disabled mode preserves whole-note Notes indexing and exposes no
    Notes/Code selectors.
  • Enable Code Mode and verify separate prose/code results in the sidebar,
    bottom view, and Semantic Search persist after restart.
  • Verify fence removal, rename, deletion, and folder exclusion update both
    indexes without stale results.
  • Rebuild with a different Code model and verify invalid-model rollback
    restores the previous usable model and index.
  • Disable and remove the Code index; confirm status becomes Disabled,
    selectors disappear, and Notes search again retrieves fenced-code content.

See docs/code-mode-spec.md for the detailed behavior contract.

@TyceHerrman
TyceHerrman marked this pull request as ready for review July 11, 2026 11:31
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.

[Feature]: Add Code Mode with separate code-block embeddings and code model setting

1 participant