Commit Graph

43 Commits

Author SHA1 Message Date
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 2f739c6f21 Refactor test mocks to access engine instances directly
Update mock retrieval to use actual instances from WorkflowEngine instead of
mocking class constructors. Flatten search result fixtures to match updated
VaultIndexer return shape.
2026-05-20 20:52:23 +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 3c7c4d58bb Add hybrid search with filtering and recency boost
Introduces SearchOptions interface with folder/tag filters, exact phrase
matching via quoted queries, and optional recency boosting with configurable
half-life. Replaces pure semantic or keyword search with a combined scoring
model: keyword scores are blended with semantic results, then adjusted by
filters and recency. Adds mtime to vault index entries and expands test
coverage for the new options.
2026-05-20 19:52:49 +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 64ee7763fe Add workflow command support to chat view
Integrate WorkflowEngine into ChatView to handle `/workflow` commands.
When a message starts with `/workflow`, the workflow engine generates
and executes a multi-step plan instead of the standard chat flow.
Results are formatted with step-by-step status and output display.

Includes workflow result formatting, assistant message updates, and
short-term context tracking. Tests verify command parsing and engine
invocation.
2026-05-20 18:58:21 +02:00
fegger 158d5f68e6 Add action preview builder for write tool confirmation
Introduces `ActionPreviewBuilder` to generate before/after previews for
destructive operations. Write tools are now deferred with apply/cancel
UI instead of executing immediately. Includes `ProposedAction` type,
CSS for diff views, and state management in `ChatView`.
2026-05-20 18:36:00 +02:00
fegger 95a6954b50 Add vault note management tools
Expand the tool executor with create_note, append_to_note, replace_note_section,
update_frontmatter, rename_note, move_note, delete_note, and insert_link tools.
Rename create_file to create_note for consistency and add helper methods for
common file operations. Update tests to cover the new tools and renamed
functionality.
2026-05-20 18:19:09 +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 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 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 138890b9d2 feat: improve UX for Ollama 404 errors (missing model)
- src/ollama-client.ts: Detect HTTP 404 on /api/chat and throw a descriptive
  ApiError with the model name and the exact ollama pull command needed.

- src/error-handler.ts: For API_ERROR type, return the error message directly
  instead of prefixing with 'API error: ', so the user-friendly 404 message
  is shown cleanly in the Obsidian notice.

- tests/ollama-client.test.ts: Update 404 assertions to match the new
  descriptive error message.
2026-05-19 21:13:08 +02:00
fegger 1ed2e39c3d fix: resolve ESLint errors and align chromadb types with bundled client
- src/semantic-cache.ts: Replace require('chromadb') with static import and
  use proper ChromaClient/Collection types instead of any. Fix camelCase
  API parameters (queryEmbeddings, nResults) and wrap single embedding into
  Embedding[] for upsert. Fix clearCache to call client.reset() instead of
  collection.reset() (matches actual chromadb API).

- src/workflow-engine/workflow-engine.ts: Fix unnecessary escapes in regex,
  remove redundant 'as unknown' assertion, handle never type in template
  literal, and add type annotations to replace callback to satisfy
  no-unsafe-argument and no-base-to-string rules.

- tests/semantic-cache.test.ts: Update mocks to include client.reset() and
  adjust clearCache assertions to match new implementation.
2026-05-19 20:44:27 +02:00
fegger 97cc4ed5fe fix: bundle chromadb and fix fetch invocation in Electron
- Bundle chromadb into main.js via esbuild instead of externalizing it.
  Obsidian's renderer cannot resolve bare require('chromadb') against a
  plugin-local node_modules. By bundling, the client library is inlined and
  works out of the box with just manifest.json + main.js.

- Remove eager cache initialization from OllamaClient constructor to avoid
  unhandled promise rejections when chromadb/ChromaDB is unavailable.

- Fix 'Failed to execute fetch on Window: Illegal invocation' by wrapping
  the default fetch fallback in an arrow function:
    this.fetchFn = fetchFn ?? ((url, init) => fetch(url, init));
  This preserves the window binding when fetch is called later.

- Update install.sh and README to remove the obsolete node_modules/chromadb
  copy step.

- Update ollama-client-cache tests to reflect that cache initialization is
  no longer eager.
2026-05-19 20:38:50 +02:00
fegger d31c989423 fix: cherry-pick improvements from feature/semantic_caching
- semantic-cache.ts: use upsert instead of add to avoid duplicate-ID errors
- semantic-cache.ts: add crypto.randomUUID() fallback for constrained runtimes
- ollama-client.ts: JSON.stringify non-string Ollama errors to avoid [object Object]
- tests: update semantic-cache mocks and assertions for upsert
2026-05-19 18:02:23 +02:00
fegger 2d78882594 chore: move compiled output to dist
Update the plugin entrypoint and TypeScript output directory to use dist instead of writing generated JavaScript into src.

Remove previously checked-in compiled source files and add coverage for the Ollama client and tool executor.
2026-05-19 17:30:05 +02:00
fegger 2e26c72c0c Add workflow engine for multi-step chained reasoning 2026-05-08 19:44:16 +02:00
fegger 52b4a6c021 Add tests for conversation state, graph view, tool executor, and vectorization 2026-05-08 18:21:20 +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 b37ca2c178 Add cache interface and semantic cache tests 2026-05-08 02:20:06 +02:00
fegger fff98d1a2e Merge branch 'modularize-indexing-pipeline' 2026-05-07 23:45:31 +02:00
fegger 951c3bbc92 Fix variable naming consistency for chroma URL configuration
Update chromaUrl to chromaURL throughout the codebase to ensure consistent naming convention for the Chroma database URL
configuration parameter. This change affects the semantic cache service implementation and related tests.

The change updates the configuration property name from `chromaUrl` to `chromaURL` in:
- SemanticCacheService class
- Test files (chat-view.test.ts, ollama-client-cache.test.ts, semantic-cache.test.ts)

This maintains consistency with other URL configuration parameters in the codebase and improves code readability.
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 d37b9f23bd Add semantic caching and indexing pipeline
This commit adds semantic caching functionality to speed up repeated queries and implements a complete indexing pipeline
for processing vault files. The changes include:

- Added semantic cache service using ChromaDB for storing and retrieving cached responses
- Implemented indexing pipeline with extraction, normalization, and vectorization steps
- Added cache configuration settings to the plugin
- Updated Ollama client to support cache integration
- Added tests for all new indexing components
- Extended vault indexer with indexing pipeline support
2026-05-07 22:23:35 +02:00
fegger b37aaeb4d4 Add semantic cache support using ChromaDB 2026-05-07 20:53:28 +02:00
fegger 4fabf1df98 Refactor lint config and retry logic 2026-05-07 14:44:59 +02:00
fegger 140198177b Guard cleanup of currentStreamController after abort 2026-05-07 14:16:53 +02:00
fegger 9823761e03 Implement stream cancellation in OllamaClient
Add `cancelStream` method to allow aborting active requests. Store the current `AbortController` on the client instance
and reset it when the stream completes or is cancelled. Update `ChatView` to call `cancelStream` on close.

Add comprehensive tests for stream cancellation scenarios, including aborting active requests, handling cancellation
when no stream is active, clearing the controller after normal completion, and allowing new streams after cancellation.
2026-05-07 12:11:01 +02:00
fegger 45993bea67 ```
Remove stream cancellation logic and refactor controller usage

Update coverage reports and tests to reflect changes
```
2026-05-07 00:59:17 +02:00
fegger 4ddef0b98f Update coverage reports with new metrics and timestamps 2026-05-07 00:43:57 +02:00
fegger 75fa07f148 ```
Remove unused isValidHttpUrl function and related tests

Remove commented-out model validation regex from constants
```
2026-05-07 00:02:32 +02:00
fegger cec8302dbe Update coverage reports and fix Ollama client abort handling 2026-05-06 23:44:29 +02:00
fegger ea792b0034 Update safeParseJson to check for dangerous object keys recursively
Improve detection of prototype pollution patterns in JSON parsing
2026-05-06 22:38:31 +02:00
fegger ccb0603d0c Update streaming handling and improve model validation
Add MAX_STREAM_CHUNKS constant and update message handling to mark streaming as complete even without tool results.
Improve model name validation to support colons and add comprehensive test suite. Refactor VaultIndexer to simplify
constructor and remove unused methods. Fix path normalization in tool executor and remove unused safeWriteFile export.
Update error handling to remove redundant console suppressions.
2026-05-06 21:48:27 +02:00
fegger aa8e45912a Update chat view tests to use new event handlers 2026-05-06 17:21:12 +02:00
fegger fd49abcdb9 Refactor error handling, client, and tests for Ollama integration 2026-05-06 16:30:16 +02:00
fegger 59df2f6856 Refactor Ollama client and related components
Update error handling and improve streaming capabilities in the Ollama client and related components. Key changes
include:

- Simplify error types and improve error handling
- Refactor streaming logic to use async generators
- Update tool execution and vault indexing
- Improve utility functions and types
- Update test files to reflect changes
2026-05-05 17:09:16 +02:00
fegger cc580889d2 ```
Update coverage reports and add new validation utilities

Add comprehensive validation utilities for Ollama URL and model name
Add new API response types and client configuration interfaces
Add Logger utility for consistent logging
Add validation function for plugin settings
Add unit tests for validation functions
Update TypeScript configuration
Update coverage reports to reflect new code additions
```
2026-05-05 00:37:18 +02:00
fegger f638b06a86 initial commit 2026-05-04 22:05:10 +02:00