Commit Graph

28 Commits

Author SHA1 Message Date
fegger 96f201bf3f Add dual-model support with separate chat and agent models
Split the single model setting into `chatModel` and `agentModel` to allow
using different LLMs for conversational modes (Ask, Research) versus
agentic modes (Edit, Organize, Workflow, auto-organizer). Defaults are
`deepseek-v4-flash` for chat and `glm-5.1` for agents.

Includes backward compatibility migration from legacy `model` field,
updated settings UI, per-mode tool filtering via new `agent-modes.ts`
configs, and vault search scoring improvements (exact phrase, recency,
filename bonuses).
2026-05-21 09:00:11 +02:00
fegger f98afcd6b0 Add tool telemetry tracking for LLM calls and vault searches
Introduces TelemetryManager to record tool calls, LLM token usage
(prompt_eval_count, eval_count), and vault search queries with timing.
Wires telemetry through ChatView, ToolExecutor, and OllamaClient with
configurable limits and enable/disable toggle.
2026-05-20 22:32:15 +02:00
fegger fbb744ba6b Add structured memory system for persistent agent context
Implements `StructuredMemoryManager` to track conversation summaries,
user preferences, and learned facts across sessions. Includes:
- Configurable storage limits with automatic enforcement
- Heuristic extraction of preferences and facts from messages
- Memory context injection into system prompts
- Full test coverage for all manager operations
2026-05-20 22:18:33 +02:00
fegger 9d4eb9a62a Add dry-run mode, target folder filtering, and tag normalization
- Add `dryRun` option to preview proposed tag/link changes without applying
- Add `targetFolder` config to restrict auto-tagging/linking to specific paths
- Add `normalizeTags` with vocabulary building to canonicalize generated tags against existing vault tags
- Update settings UI with new toggles and text inputs for both auto-tag and auto-link sections
2026-05-20 22:04:05 +02:00
fegger 2db7c34920 Add configurable agent modes with per-mode tool filtering
Introduces `ask`, `edit`, `organize`, `research`, and `workflow` modes.
Each mode defines its own system prompt, allowed tools, and preview
requirements. The active mode can be switched via a dropdown in the
chat UI and defaults can be set in plugin settings. Mode selection
affects which tools are exposed to the LLM and whether write actions
require user preview before execution.
2026-05-20 21:49:41 +02:00
fegger 106abfa718 Integrate Obsidian metadataCache across extraction and tooling
Replaces regex-based parsing of frontmatter and headings with
Obsidian's metadataCache where available, falling back to regex
when the cache is unavailable. Propagates App dependency through
constructors to enable cache access.

Key changes:
- ContentExtractor accepts optional cache for frontmatter/headings
- ToolExecutor uses cache for section replacement and frontmatter
- NoteContextBuilder resolves titles/tags from cache
- VaultVectorStore passes cache through indexing pipeline
- AutoTagger checks cache for existing tags instead of content
- Mock updated with metadataCache stubs for tests
2026-05-20 20:36:47 +02:00
fegger 3abacb5d6e Add NoteContextBuilder for enhanced chat context gathering
Introduces NoteContextBuilder to extract explicit wikilink mentions,
detect scope intent, and gather contextual note data including
backlinks, outlinks, and related notes. Integrates into ChatView
and adds comprehensive unit tests.

Also includes minor type fixes: removes unnecessary `as` cast in
action-preview-builder, fixes non-null assertion in tool-executor,
and cleans up unused import in auto-organizer. Simplifies auto-tag
command callback by removing redundant async/await.
2026-05-20 19:17:42 +02:00
fegger 8e338afeac feat: increase vault context limits and make them configurable
- Replace hardcoded 2000-char context limit with configurable maxContextLength
  setting (default: 8000 characters)
- Increase vaultSearchLimit default from 3 to 5 notes
- Add 'Max Context Length' setting to plugin settings UI
- Update README with new defaults
- Update chat-view tests for new setting
2026-05-20 01:20:49 +02:00
fegger a8d8936b11 feat: add auto-tag and auto-link note organization features
- Add AutoTagger: scans untagged notes, generates AI tags via Ollama,
  and applies them to frontmatter
- Add AutoLinker: finds semantically related notes via vault search
  and appends a 'Related Notes' section with wiki-links
- Add settings UI for both features with configurable thresholds,
  prompt templates, and limits
- Add commands: 'Auto-Tag Untagged Notes' and 'Auto-Link Related Notes'
- Add auto-organizer.test.ts with 17 tests covering tagging,
  linking, frontmatter manipulation, and filtering
2026-05-20 00:12:30 +02:00
fegger cb621c83b5 fix: process embeddings sequentially, shorten prompts, fix tests
- main.ts: process files sequentially (not Promise.all) to avoid concurrent
  embedding requests hammering Ollama; batch size reduced to 1
- vectorization.ts: shorten embedding prompts from 1000 to 500 chars,
  limit headings to 5, remove frontmatter from prompt to stay well within
  embedding model context window
- Update vectorization and indexing-pipeline tests for new prompt format
2026-05-19 23:51:29 +02:00
fegger cc97d77810 fix: use collection deletion instead of reset, add embedding retry, slow down indexing
- semantic-cache.clearCache: delete collection instead of client.reset()
  to avoid 403 Forbidden on newer ChromaDB versions
- vault-vector-store.clearIndex: same collection deletion approach
- ContentVectorizer: add 3-attempt retry with exponential backoff (1s, 2s, 4s)
- main.ts: reduce indexing batch size from 5 to 2, increase delay from 100ms to 500ms
- Update semantic-cache tests for deleteCollection
2026-05-19 23:41:05 +02:00
fegger ce109cf6fb fix: prevent race conditions during vault index rebuild and rate-limit embeddings
- Add AbortController to cancel ongoing indexing before clear/rebuild
- Track currentIndexingPromise to await cancellation before clearing collection
- Batch background indexing (5 files at a time) with 100ms delays between batches
- Skip incremental event-based indexing while a full rebuild is in progress
- Cancel indexing on plugin unload
- Fix nginx CORS headers on OPTIONS preflight responses
2026-05-19 23:29:34 +02:00
fegger fae74ade95 feat: add semantic/RAG vault indexing with automatic background sync
- Add VaultVectorStore backed by ChromaDB for vector-based vault search
- Integrate existing ContentVectorizer/IndexingPipeline for embeddings
- Update VaultIndexer to prefer semantic search with keyword fallback
- Background indexing on plugin load + incremental sync via vault events
- Add vault index settings, commands, and UI controls
- Add tests for VaultVectorStore
- Update README with RAG setup instructions
2026-05-19 23:00:04 +02:00
fegger 1ccd637149 fix: sanitize ChromaDB URL and update docker-compose CORS config
- src/semantic-cache.ts: Add robust URL sanitization in initialize().
  Trim whitespace and reject malformed URLs (e.g. empty host like
  'http://:8666') before passing to ChromaClient.

- src/main.ts: Validate ChromaDB URL in the settings tab onChange.
  Fall back to 'http://localhost:8000' if the value is empty or lacks
  '://'.

- docker-compose.yml: Add CHROMA_SERVER_CORS_ALLOW_ORIGINS=["*"] to
  allow cross-origin requests from Obsidian's app://obsidian.md origin.
2026-05-19 21:59:35 +02:00
fegger 810676ff21 feat: add Ollama icon and modern chat UI styling
- src/chat-view.ts: Add getIcon() returning 'bot' for the view tab icon.
  Improve render() with role-specific CSS classes (user vs assistant) and
  message header structure for better styling hooks.

- src/main.ts: Add ribbon icon ('bot') in the left sidebar that opens the
  chat view with a single click.

- styles.css (new): Modern chat UI with message bubbles, distinct user and
  assistant themes using Obsidian CSS variables, sticky input bar, styled
  send button with accent color, and emoji role indicators.

- install.sh: Copy styles.css into the plugin directory and verify its
  presence during installation.

- README.md: Include styles.css in manual install instructions.

- __mocks__/obsidian.ts: Add addRibbonIcon() mock for test compatibility.

- tests/chat-view.test.ts: Add getIcon() assertion.
2026-05-19 21:18:56 +02:00
fegger 771db09d24 Refactor chat view and add conversation state management
Introduce ConversationStateManager to handle short, medium, and long-term
context for improved conversation flow. Update ChatView to use this manager
and refactor input handling to accept values directly for better testability.

Update OllamaClient with non-streaming chat support and improved error
handling for malformed chunks. Enhance vault indexer with caching, better
scoring, and stop word filtering. Refactor main plugin entry point and
semantic cache initialization for robustness.
2026-05-08 11:52:31 +02:00
fegger 6bc1133a81 Refactor type annotations and error handling in core modules
Standardize error message extraction to handle non-Error objects.
Add explicit return types and interface definitions to VaultIndexer.
Update SemanticCacheService to use any types where necessary.
Rename SemanticCache to SemanticCacheService and adjust imports.
2026-05-08 02:19:44 +02:00
fegger fff98d1a2e Merge branch 'modularize-indexing-pipeline' 2026-05-07 23:45:31 +02:00
fegger 6423e2aa0d Clean up settings display and remove validation logic
Remove unused imports and simplify Ollama client stream handling

Add configurable ChromaDB host and UUID fallback

Refactor vault indexer to use tokenized content and improve caching
2026-05-07 23:23:32 +02:00
fegger d4a0919764 Fix merge conflicts and apply all semantic cache fixes 2026-05-07 22:49:07 +02:00
fegger ae16396a7a Integrate semantic cache with ChromaDB URL 2026-05-07 22:47:32 +02:00
fegger 179a58b95b Add semantic cache support using ChromaDB 2026-05-07 22:47:01 +02:00
fegger b37aaeb4d4 Add semantic cache support using ChromaDB 2026-05-07 20:53:28 +02:00
fegger 3ab326ffc2 Refactor retry logic and extract scoring weights 2026-05-07 19:02:36 +02:00
fegger 579e60f5d5 ```
Increase test coverage across multiple modules (91.2% statements, 82.85% branches, 82.35% functions, 93.1% lines)

Update abort controller handling in OllamaClient to properly clean up previous controllers

Remove unused imports and constants: MODEL_NAME_REGEX, MouseEvent, DEFAULT_SETTINGS, convertMarkdownToHtml

Refactor event handler naming to be more consistent
```
2026-05-06 22:30:29 +02:00
fegger d57ade0ba8 Update coverage reports and improve error handling 2026-05-06 19:28:40 +02:00
fegger 2968932d69 Add error handler and improve coverage 2026-05-06 18:24:24 +02:00
fegger fd49abcdb9 Refactor error handling, client, and tests for Ollama integration 2026-05-06 16:30:16 +02:00