8 Commits

Author SHA1 Message Date
f8c7b6d53f feat: add word count support for read operations
Extended word count functionality to read operations (read_note, stat, list) to complement existing write operation support.

Changes:
- read_note: Now automatically includes wordCount when returning content (with withContent or parseFrontmatter options)
- stat: Added optional includeWordCount parameter with performance warning
- list: Added optional includeWordCount parameter with performance warning
- All operations use same word counting rules (excludes frontmatter and Obsidian comments)
- Best-effort error handling for batch operations

Technical details:
- Updated ParsedNote and FileMetadata type definitions to include optional wordCount field
- Added comprehensive test coverage (18 new tests)
- Updated tool descriptions with usage notes and performance warnings
- Updated CHANGELOG.md to document new features in version 1.1.0
2025-10-30 11:14:45 -04:00
00deda4347 test: add vault-tools defensive code coverage
- Added test for getFolderWaypoint file read error handling (line 777)
- Documented unreachable defensive code in stat() (lines 452-456)
- Documented unreachable defensive code in exists() (lines 524-528)
- Added istanbul ignore comments for unreachable defensive returns

Analysis:
- Lines 452-456 and 524-528 are unreachable because getAbstractFileByPath
  only returns TFile, TFolder, or null - all cases are handled before
  the defensive fallback code
- Line 777 is now covered by testing file read errors in getFolderWaypoint

Coverage: vault-tools.ts now at 100% statement coverage (99.8% tools overall)
Test count: 84 vault-tools tests, 505 total tests passing
2025-10-25 22:14:29 -04:00
c54c417671 test: add vault-tools edge case tests
- Add test for list() skipping root folder (line 267)
- Add test for list() normalizing aliases from string to array (line 325)
- Add test for list() handling array aliases (line 325)
- Add test for getFolderMetadata() handling folder with mtime (line 374)
- Add test for getFolderMetadata() handling folder without mtime
- Add test for list() on non-root path (line 200)
- Add test for search() stopping at maxResults=1 on file boundary (line 608)
- Add test for search() stopping at maxResults=1 within file (line 620)
- Add test for search() adjusting snippet for long lines (line 650)

Coverage improved from 95.66% to 98.19% for vault-tools.ts
2025-10-25 22:14:29 -04:00
8e1c2b7b98 test: add vault-tools invalid path and glob tests
Added targeted test cases to improve vault-tools.ts coverage:

- Test for listNotes() with invalid vault path (covers line 76)
- Test for list() with glob excludes filtering (covers line 272)
- Test for search() with glob include/exclude patterns (covers lines 596-597)

Coverage improved from 94.22% to 95.66% for vault-tools.ts.
All tests passing (75 tests).
2025-10-25 22:14:29 -04:00
3360790149 refactor: update VaultTools to pass adapters to utils
Updated VaultTools to use adapters for all utility method calls:
- SearchUtils.searchWaypoints() now receives vault adapter
- WaypointUtils.isFolderNote() now receives vault adapter
- LinkUtils.validateWikilinks() now receives vault and metadata adapters
- LinkUtils.resolveLink() now receives vault and metadata adapters
- LinkUtils.getBacklinks() now receives vault and metadata adapters

Removed App dependency from VaultTools constructor - now only requires
vault and metadata adapters. Updated factory and all test files accordingly.

All tests passing (336/336).
2025-10-25 22:14:29 -04:00
5760ac9b8b test: add comprehensive VaultTools coverage tests
Added extensive test coverage for VaultTools to increase coverage from 54.9% to 93.83%:

getVaultInfo tests:
- Return vault info with total notes and size
- Handle empty vault
- Handle files with missing stat info
- Handle errors gracefully
- Format large file sizes correctly (KB, MB, GB)

search tests:
- Search for literal text
- Search with regex pattern
- Handle invalid regex pattern
- Filter by folder
- Respect maxResults limit
- Handle file read errors gracefully
- Handle case sensitive search
- Extract snippets correctly
- Handle zero-width regex matches
- Handle general search errors

Waypoint tests (searchWaypoints, getFolderWaypoint, isFolderNote):
- Search for waypoints in vault
- Filter waypoints by folder
- Extract waypoint from file
- Detect folder notes
- Handle file not found errors
- Handle general errors

resolveWikilink tests:
- Resolve wikilink successfully
- Provide suggestions for unresolved links
- Handle errors gracefully
- Handle invalid source path

getBacklinks unlinked mentions tests:
- Find unlinked mentions
- Skip files that already have linked backlinks
- Skip target file itself in unlinked mentions
- Not return unlinked mentions when includeUnlinked is false

list edge case tests:
- Handle invalid path
- Handle non-existent folder
- Handle path pointing to file instead of folder
- Handle cursor not found in pagination

validateWikilinks edge case tests:
- Handle invalid path
2025-10-20 00:20:12 -04:00
aca4d35944 test: add coverage for VaultTools uncovered paths
Add tests for:
- getBacklinks with snippet options (includeSnippets true/false)
- getBacklinks error handling (file not found, read errors)
- validateWikilinks error paths (file not found, read errors)
- validateWikilinks successful validation with resolved/unresolved links

Improves vault-tools.ts coverage from 35.85% to 54.9% statements.
Adds 7 new tests (27 to 34 total).
2025-10-19 23:48:36 -04:00
862c5533e8 test: update vault-tools tests to use mock adapters
Replace complex App object mocks with clean mock adapter pattern.
Simplifies test setup and improves maintainability.

- Created comprehensive tests for VaultTools methods using mock adapters
- Tests cover listNotes, stat, exists, and list (enhanced) functionality
- Includes tests for frontmatter extraction edge cases
- Fixed mock helpers to use proper prototype chains for instanceof checks
- All 27 VaultTools tests passing
2025-10-19 23:34:28 -04:00