Commit graph

50 commits

Author SHA1 Message Date
Andrew Beal
3e43d9f558 refactor: improve legacy tool call conversion format and system prompt clarity
Simplify historical tool call/result format from bracketed text to JSON with HTML comments indicating completed status. Update system prompt to clarify this is historical context, not a pattern to reproduce. Improve chat area layout performance with debouncing and reduce minimum padding. Update all tests to match new format.
2025-12-12 23:37:30 +00:00
Andrew Beal
ad46a0fa7f fix: use cursor position for search query extraction instead of full text 2025-12-11 17:11:41 +00:00
Andrew Beal
a86d784888 refactor: remove unused backspace handling and element detection logic
Remove custom backspace key handler in ChatInput and unused getElementBeforeCursor method in InputService. Clean up unused imports and associated test cases.
2025-12-11 12:41:14 +00:00
Andrew Beal
565bfdfda7 Refactor: move legacy function conversion to BaseAIClass
Consolidate convertFunctionCallToText and convertFunctionResponseToText
methods from Claude and Gemini into BaseAIClass for code reuse. Update
OpenAI to handle missing function call IDs by converting to legacy text
format, preventing undefined call_id bugs during cross-provider switches.
2025-12-10 21:47:27 +00:00
Andrew Beal
d36815c214 feat: add Gemini thought signature support and OpenAI Responses API migration
Implement thought signature tracking for Gemini function calls to support Gemini 3 requirements. Migrate OpenAI integration from Chat Completions to Responses API with proper input/output item handling. Add cross-provider compatibility via legacy text format fallback for conversations without thought signatures or tool IDs. Improve chat auto-scroll behavior and conversation validation. Add and update AI class and conversation tests.
2025-12-10 21:27:58 +00:00
Andrew Beal
51a30613a3 test: update FileSystemService error message assertion 2025-12-07 13:45:20 +00:00
Andrew Beal
33440d17bf refactor: standardize error handling and logging across codebase
Replace console.error/log with Exception.log helper, improve OpenAI error handling with retryable errors, add type-safe model validation, and add new AI models (Claude Opus 4.5, Gemini 3 Pro Preview, GPT-5.1)
2025-12-06 14:09:46 +00:00
Andrew Beal
065d475d74 Refactor file patching from unified diff to direct string replace
This change simplifies the patch mechanism by replacing the unified diff format with a straightforward find-and-replace approach. The PatchVaultFile function now accepts oldContent and newContent parameters instead of a diff patch string, making it more intuitive and reliable for AI agents to use.

Key changes:
- Update PatchVaultFile function signature and documentation
- Replace diff.applyPatch() with String.replace()
- Simplify error handling for content matching
- Update all tests to reflect new API
- Remove unused applyPatch method from DiffService
- Fix diff container height calculation in CSS
- Fix error notification logic in ChatService
- Fix conversation deletion order in TopBar component
2025-12-05 23:02:55 +00:00
Andrew Beal
f7ff10699d Add PatchVaultFile function for incremental file updates
Implements unified diff patching as an alternative to WriteVaultFile for making targeted changes without replacing entire files. Includes new PatchVaultFile AI function, DiffService.applyPatch method, and comprehensive test coverage.
2025-12-05 22:48:54 +00:00
Andrew Beal
28772e7d0e feat: implement centralized abort controller with enhanced cancellation UX
Introduce a new AbortService to centralize cancellation logic across all async operations, replacing scattered AbortSignal parameters with a unified singleton service. This improves maintainability and provides consistent cancellation behavior throughout the application.

Key changes:
- Add AbortService for centralized abort signal management with automatic cleanup
- Refactor all AI providers (Claude, Gemini, OpenAI) to use AbortService instead of passing AbortSignal parameters
- Update streaming operations to use centralized abort handling
- Add CancellationIndicator component to show visual feedback during operation cancellation
- Rename ChatAreaThought to ThoughtIndicator for better semantic clarity
- Add Environment enum for consistent environment detection
- Enhance ChatService lifecycle with proper cancellation state management
- Remove scattered abort-related UI selectors and error messages in favor of dedicated indicator
- Add safeContinue() factory method to ConversationContent for internal continuations
- Update all tests to reflect new abort handling architecture

This change simplifies the API surface by removing AbortSignal parameters from method signatures while improving the user experience with clearer cancellation feedback.
2025-12-04 23:04:20 +00:00
Andrew Beal
2d5a1b52bf feat: add interactive diff viewer with user approval workflow
Implement a comprehensive diff viewing system that allows users to review and approve/reject file changes before they're applied. The system includes event-driven architecture for managing diff lifecycle and integrates diff2html for rich visual diffs.

Key changes:
- Add DiffService for managing diff approval workflow with accept/reject/suggest actions
- Create EventService for type-safe event handling (DiffOpened/DiffClosed)
- Add DiffView component with diff2html integration for visual diff rendering
- Modify VaultService to propose changes and require confirmation before file operations
- Update FileSystemService to support optional confirmation for write operations
- Add Event enum for centralized event type definitions
- Import custom styles and diff2html styles for proper diff rendering
- Update ConversationContent validation to support optional toolId field
- Remove FileManager from dependency injection (now accessed directly from app)
- Update .gitignore to track styles.css instead of main.css
2025-11-24 21:29:54 +00:00
Andrew Beal
6ec1c8aeb9 refactor: extract shared AI provider logic to BaseAIClass
Consolidate duplicate code from Claude, Gemini, and OpenAI implementations into a new BaseAIClass with common methods for parsing, filtering conversation contents, and error handling. Filter orphaned function calls without responses from conversation history to prevent API errors.
2025-11-24 09:11:07 +00:00
Andrew Beal
46afa2766f test: add comprehensive performance tests for VaultCacheService
Adds 51 performance tests covering initial cache loading (1K-20K files),
fuzzy search operations (tags/files/folders), and real-time updates with
configurable thresholds and detailed performance metrics logging.
2025-11-19 20:50:48 +00:00
Andrew Beal
18372ce01b refactor: improve error handling with structured API errors and retry logic
Replace console.error calls with Exception.log, implement typed API errors with automatic retry for transient failures (rate limits, server errors), add error state tracking to conversation content, and enhance system prompt with action-first operating principle, update unit tests
2025-11-19 20:30:53 +00:00
Andrew Beal
167a2b13a5 refactor: standardize error handling with Exception helper and improve return types
Add Exception helper class for consistent error handling and logging. Replace throw statements and console.error calls with Exception methods. Update service methods to return Error | T instead of mixed success/failure objects. Improve type safety in Claude.extractContents with explicit return type.

Add WikiLinks helper to VaultCacheService for managing wiki link references.

Update unit tests.
2025-11-17 19:02:15 +00:00
Andrew Beal
d7eefae936 refactor: migrate OpenAI integration to Responses API. Add web search capabilities.
Remove 'gpt-4.1-nano' which does not support web search.

Replace Chat Completions API with OpenAI Responses API throughout codebase. Update event parsing from delta-based streaming to event-based model, restructure request format to use instructions/input instead of messages array, and revise conversation naming service to handle new response structure.
2025-11-14 10:24:46 +00:00
Andrew Beal
911165b15d Optimize vault search with parallel processing and early termination
- Add shuffleArray helper function for randomized file processing
- Process files in parallel batches to improve search performance
- Implement early termination when sufficient matches are found
- Optimize snippet extraction to reduce redundant text operations
- Simplify search result structure to reduce memory overhead
- Update setting description to mention increased search time
- Fix test mocks for empty search term handling
2025-11-12 21:49:16 +00:00
Andrew Beal
fbe5766d03 refactor: consolidate string utilities into StringTools class
Move isValidJson, dateToString, and escapeRegex from Helpers to new StringTools class. Add asRegex method for parsing regex literals with /pattern/flags format. Update all imports and usages across codebase.
2025-11-12 21:12:36 +00:00
Andrew Beal
f6f540ede9 fix: handle legacy function calls without IDs in Claude provider
Add validation to check for missing or empty function call IDs when
converting stored conversation history. Function calls and responses
without valid IDs are now converted to text format with [Legacy Tool Call]
and [Legacy Tool Result] prefixes to preserve context when switching
between providers.

Also improve ConversationHistoryModal initialization, add empty state
copy constant, enhance system prompt with regex pattern guidance, and
clean up formatting.
2025-11-11 23:46:53 +00:00
Andrew Beal
dc192a98fe refactor: change writeFile to return Error | undefined instead of boolean
Update FileSystemService.writeFile return type from boolean | Error to Error | undefined for cleaner error handling pattern. Adjust AIFunctionService and tests accordingly.
2025-11-11 19:54:11 +00:00
Andrew Beal
a30693bfe5 refactor: convert AIFunctionCall.name from string to AIFunction enum
- Add AIFunction enum type to AIFunctionCall name property
- Implement fromString helper to convert string to AIFunction
- Update Claude, Gemini, and OpenAI classes to use aiFunctionFromString
- Add type safety to AIFunctionService switch statement
- Update all test files to use AIFunction enum values
2025-11-10 20:08:32 +00:00
Andrew Beal
37db1a8908 refactor: improve type safety and add Zod validation for function arguments
- Change function arguments type from `Record<string, object>` to `Record<string, unknown>`
- Add Zod schemas for all AI function arguments validation
- Improve TypeScript types across modals and services
- Add ESLint disable comments for intentional exceptions
- Fix async/await handling in modal and view lifecycle methods
- Update dependencies (@typescript-eslint 8.46.4, rollup 4.53.2, zod 4.1.12)
2025-11-10 19:41:17 +00:00
Andrew Beal
235609dc4c refactor: improve type safety and remove unused imports
- Add explicit type casting for API call results
- Fix regex escape sequences to use Unicode notation
- Remove unused type imports across multiple services
- Update file deletion to use FileManager.trashFile
- Add missing switch case for folder modify events
- Move CSS imports to ES6 import syntax
2025-11-10 13:44:16 +00:00
Andrew Beal
643129517a refactor: convert TypeScript namespaces to standalone functions
Migrate AIProvider and SearchTrigger from namespace pattern to exported functions. Simplify OpenAITokenService async implementation, remove unused imports, fix enum aliases, and update placeholder text.
2025-11-10 12:59:48 +00:00
Andrew Beal
96a90452f8 refactor: replace custom type definitions with official SDK types
Remove custom interface definitions for Claude, OpenAI, and Gemini APIs in favor of importing types directly from official SDKs (@anthropic-ai/sdk, openai, @google/genai). Add openai package dependency and update StoredFunctionResponse interface to include name field.
2025-11-10 12:39:05 +00:00
Andrew Beal
a217e84643 Rename plugin to Vaultkeeper AI 2025-11-10 08:03:27 +00:00
Andrew Beal
ff111c69e6 Rename from AI Agent to Vault AI 2025-11-09 23:09:08 +00:00
Andrew Beal
0812e91c37 fix: prevent empty messages and assistant-to-assistant structure
- Filter out messages with empty content in Claude, Gemini, and OpenAI
- Insert hidden "Continue" message when last message is from assistant
- Remove function call JSON from assistant message content
- Hide empty messages in ChatArea UI
- Add GitHub link and about content to help modal
- Add comprehensive tests for message handling edge cases
2025-11-09 13:57:47 +00:00
Andrew Beal
4d8edc8b96 Update delete functionality to support folders and use trash
- Enhance DeleteVaultFiles to handle both files and folders
- Change VaultService.delete to use vault.trash instead of permanent deletion
- Remove TFile type check to allow folder deletion
- Simplify delete method signature by removing unused force parameter
- Increase default snippet size limit from 150 to 300 characters
- Fix IPrompt to use SettingsService instead of direct plugin access
- Update all tests to reflect trash behavior and folder support
2025-11-03 21:37:47 +00:00
Andrew Beal
ee8da0e6a5 feat: add configurable search results and snippet size limits
Add user-configurable settings for search results limit (5-40) and snippet size limit (50-1000 chars) to control AI context usage. Update VaultService to use these limits instead of hardcoded values. Include comprehensive test coverage.
2025-11-03 20:46:23 +00:00
Andrew Beal
74560ae685 refactor: centralize API key management with SettingsService
Move API key storage from single key to per-provider keys. Extract
settings logic from plugin to new SettingsService, updating all AI
classes and components to use centralized service. Add visual
indicators for active user instructions in UI.
2025-11-03 17:14:32 +00:00
Andrew Beal
c0178dc364 feat: add multi-term search and user instruction UI with file path setting
Refactor SearchVaultFiles to accept array of search terms, add user instruction panel in chat input with toggle button, move user instruction path to settings (from hardcoded), improve search result interaction with mouse/keyboard support, fix async exists() method in VaultService, and create example instructions file on first launch
2025-11-02 20:16:06 +00:00
Andrew Beal
0a7d95e0fe Add tests for FileSystemService. 2025-11-01 15:15:16 +00:00
Andrew Beal
0851e81d7b refactor: replace direct DOM manipulation with HTMLService
Introduces HTMLService to centralize HTML/DOM operations and updates
SearchTrigger, StreamingMarkdownService, and tests to use the new
service instead of directly manipulating innerHTML and DOM methods.
2025-11-01 13:27:53 +00:00
Andrew Beal
f8f606bdf6 test: remove unused imports and update type references 2025-11-01 11:50:11 +00:00
Andrew Beal
72ddbba72e feat: add ListVaultFiles function and improve search behavior
- Add new ListVaultFiles AI function for listing vault contents
- Remove auto-fallback to listing all files when search returns 0 results
- Improve SearchVaultFiles description to clarify it searches content
- Add listFoldersInDirectory and listDirectoryContents methods to VaultService
- Update SanitiserService to normalize empty strings to "/" (vault root)
- Add allowAccessToPluginRoot parameter to searchVaultFiles
- Update tests to reflect new search behavior and list operations
- Add DeregisterAllServices call in plugin onunload
- Update dependencies (@google/genai, svelte, vitest, eslint)
2025-11-01 11:43:32 +00:00
Andrew Beal
ba8db87ffd refactor: use promptContent for user messages across AI providers
Standardize message extraction logic to use promptContent field for user roles and content field for assistant roles. Update all AI provider implementations (Claude, OpenAI, Gemini) and corresponding tests. Remove trailing space insertion in ChatInput and clean up minor formatting issues.
2025-10-31 18:32:40 +00:00
Andrew Beal
a3d0b55100 refactor: improve backspace handling for non-editable elements
Replace getNodeAtCursorPosition with getElementBeforeCursor for more robust element detection before cursor. Add cursor position validation after deletions to prevent cursor from ending up inside contenteditable="false" elements. Remove unused helper methods and reorganize code structure.
2025-10-31 18:03:00 +00:00
Andrew Beal
eab7e77303 Add test coverage for InputService. 2025-10-31 15:12:31 +00:00
Andrew Beal
5d3cde18c7 feat: implement rich text input with search trigger system
Add contenteditable chat input supporting inline search triggers for tags, files, and folders. Implement custom backspace/paste/drop handlers, trigger-to-text conversion for API requests, and improved cursor position management. Fix vault exclusion logic to properly cache non-excluded files.
2025-10-31 15:03:40 +00:00
Andrew Beal
f2d5c01970 test: add cleanup to prevent memory leaks in test suites
Add DeregisterAllServices() calls in afterEach hooks across all test files to clear singleton registry between tests. Export DeregisterAllServices from DependencyService. Fix StatusBarService test timing issues with animation frames.
2025-10-30 12:15:35 +00:00
Andrew Beal
3852194f2d add: new unit / integration tests
fix: standardize error messages and improve cache path filtering

Standardize "Error parsing function call" message across Claude and OpenAI providers. Fix VaultCacheService to properly handle file events when paths move in/out of cached folders. Update test documentation and setup for Session 4.
2025-10-30 09:33:05 +00:00
Andrew Beal
211b8905ca fix: prevent caching of excluded folders in VaultCacheService
Check VaultService exclusions before caching folders on create/rename events to prevent excluded directories (AI Agent root, user exclusions) from being added to the cache.
2025-10-29 22:06:22 +00:00
Andrew Beal
63bcfdeae9 fix: remove min query length requirement and improve search UI styling
- Remove 3-character minimum search query requirement
- Add dynamic padding to search results container
- Style search results with icons, grid layout, and hover states
- Fix missing semicolons in ChatInput event handlers
- Implement auto-scroll for selected search result
- Initialize vault cache after metadata resolution
- Update tests to reflect removed query length validation
2025-10-29 21:33:45 +00:00
Andrew Beal
063dee3057 Write unit tests for InputService. 2025-10-29 19:59:52 +00:00
Andrew Beal
08706ccdd0 Create unit tests for UserInputService 2025-10-29 19:52:15 +00:00
Andrew Beal
e551155230 Add promptContent parameter to ConversationContent class
This change adds a new promptContent parameter to the ConversationContent
constructor and updates all related code including serialization,
deserialization, and tests to support this new field.
2025-10-29 19:41:05 +00:00
Andrew Beal
44cfa54e95 feat: add fuzzy search for tags, files, and folders in vault cache
Implement fuzzysort-based matching methods (matchTag, matchFile, matchFolder)
with automatic preparation of search targets. Add folder tracking alongside
existing file/tag caching. Update event handlers to maintain fuzzy search
indices on create/rename/delete operations.
2025-10-25 16:17:45 +01:00
Andrew Beal
182d12173a feat: add VaultCacheService and vault monitoring capabilities
Register VaultCacheService as singleton dependency, add file event registration to VaultService for monitoring vault changes, implement listVaultContents method to retrieve all files and folders with exclusion filtering, and add comprehensive test coverage for new functionality.
2025-10-25 12:46:07 +01:00
Andrew Beal
a35269550d Bump package versions.
Setup Vitest.
Create unit and integration tests.
Co-authored by Claude.
2025-10-24 23:36:55 +01:00