Phase 2: API Unification & Typed Results + Phase 2.1 Fixes

Phase 2 - Breaking Changes (v2.0.0):
- Added typed result interfaces (FileMetadata, DirectoryMetadata, VaultInfo, SearchResult, SearchMatch)
- Unified parameter naming: list_notes now uses 'path' parameter (removed 'folder')
- Enhanced tool responses with structured JSON for all tools
- list_notes: Returns array of FileMetadata/DirectoryMetadata with full metadata
- search_notes: Returns SearchResult with line numbers, snippets, and match ranges
- get_vault_info: Returns VaultInfo with comprehensive statistics
- Updated all tool descriptions to document structured responses
- Version bumped to 2.0.0 (breaking changes)

Phase 2.1 - Post-Testing Fixes:
- Fixed root listing to exclude vault root folder itself (handles path '', '/', and isRoot())
- Fixed alphabetical sorting to be case-insensitive for stable ordering
- Improved directory metadata with better timestamp detection and error handling
- Fixed parent folder validation order (check if file before checking existence)
- Updated documentation with root path examples and leading slash warnings
- Added comprehensive test suite for sorting and root listing behavior
- Fixed test mocks to use proper TFile/TFolder instances

Tests: All 64 tests passing
Build: Successful, no errors
This commit is contained in:
2025-10-16 22:49:28 -04:00
parent d074470d11
commit 9d07ec64e2
13 changed files with 1043 additions and 70 deletions

View File

@@ -43,7 +43,9 @@ describe('Enhanced Parent Folder Detection', () => {
});
test('should detect when parent path is a file, not a folder', async () => {
const mockFile = { path: 'parent.md' } as TFile;
// Create a proper TFile instance
const mockFile = Object.create(TFile.prototype);
Object.assign(mockFile, { path: 'parent.md', name: 'parent.md', basename: 'parent', extension: 'md' });
// Setup: parent path exists but is a file
vault.getAbstractFileByPath.mockImplementation((path: string) => {
@@ -222,7 +224,9 @@ describe('Enhanced Parent Folder Detection', () => {
});
test('should provide clear error when parent is a file', async () => {
const mockFile = { path: 'file.md' } as TFile;
// Create a proper TFile instance
const mockFile = Object.create(TFile.prototype);
Object.assign(mockFile, { path: 'file.md', name: 'file.md', basename: 'file', extension: 'md' });
vault.getAbstractFileByPath.mockImplementation((path: string) => {
if (path === 'file.md') return mockFile;