feat: Phase 9 - Linking & Backlinks
Implement three new tools for wikilink validation, resolution, and backlink queries: New Tools: - validate_wikilinks: Validate all wikilinks in a note with suggestions for broken links - resolve_wikilink: Resolve a single wikilink to its target path - backlinks: Get all backlinks to a note with optional unlinked mentions New Files: - src/utils/link-utils.ts: Complete wikilink parsing, resolution, and backlink utilities Modified Files: - src/tools/vault-tools.ts: Added 3 new methods for link operations - src/tools/index.ts: Added 3 tool definitions and handlers - src/types/mcp-types.ts: Added Phase 9 type definitions - ROADMAP.md: Marked Phase 9 as complete - CHANGELOG.md: Added v8.0.0 release notes Key Features: - Regex-based wikilink parsing with position tracking - Uses MetadataCache.getFirstLinkpathDest() for accurate resolution - Fuzzy matching suggestion engine for broken links - Efficient backlink detection using MetadataCache.resolvedLinks - Optional unlinked mentions with word-boundary matching - Context snippet extraction for each occurrence
This commit is contained in:
@@ -284,3 +284,70 @@ export interface DeleteNoteResult {
|
||||
dryRun: boolean;
|
||||
soft: boolean;
|
||||
}
|
||||
|
||||
// Phase 9: Linking & Backlinks Types
|
||||
|
||||
/**
|
||||
* Resolved wikilink information
|
||||
*/
|
||||
export interface ResolvedLink {
|
||||
text: string;
|
||||
target: string;
|
||||
alias?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unresolved wikilink information
|
||||
*/
|
||||
export interface UnresolvedLink {
|
||||
text: string;
|
||||
line: number;
|
||||
suggestions: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Result from validate_wikilinks operation
|
||||
*/
|
||||
export interface ValidateWikilinksResult {
|
||||
path: string;
|
||||
totalLinks: number;
|
||||
resolvedLinks: ResolvedLink[];
|
||||
unresolvedLinks: UnresolvedLink[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Result from resolve_wikilink operation
|
||||
*/
|
||||
export interface ResolveWikilinkResult {
|
||||
sourcePath: string;
|
||||
linkText: string;
|
||||
resolved: boolean;
|
||||
targetPath?: string;
|
||||
suggestions?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Backlink occurrence in a file
|
||||
*/
|
||||
export interface BacklinkOccurrence {
|
||||
line: number;
|
||||
snippet: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backlink from a source file
|
||||
*/
|
||||
export interface BacklinkInfo {
|
||||
sourcePath: string;
|
||||
type: 'linked' | 'unlinked';
|
||||
occurrences: BacklinkOccurrence[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Result from backlinks operation
|
||||
*/
|
||||
export interface BacklinksResult {
|
||||
path: string;
|
||||
backlinks: BacklinkInfo[];
|
||||
totalBacklinks: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user