Skip to content

feat(citation-validator): warn when markdown links point to folders #3

@WesleyMFrederick

Description

@WesleyMFrederick

Problem

Citation-manager validate currently passes folder links as valid citations. While these are syntactically correct markdown links, they cause issues in practice:

  • Obsidian: Cannot preview folder links (shows broken preview)
  • User expectation: Links should point to readable content
  • False positives: Invalid links pass validation

Reproduction Steps

  1. Validate a file containing a folder link:
- [Research Examples](research/) - Sample interviews and brick extractions
  1. Observe validation passes with no warnings:
Citation Validation Report
==========================
VALID CITATIONS (2)
├─ Line 99: [Architecture Principles](../ARCHITECTURE-PRINCIPLES.md)
└─ Line 100: [Full Architecture](ARCHITECTURE-Evidence-Tracker.md)

ALL CITATIONS VALID

Note: The folder link research/ at line 101 is not even detected/reported.

Proposed Solution

Add validation check for folder links:

if (fs.statSync(resolvedPath).isDirectory()) {
  warnings.push({
    line,
    type: 'folder-link',
    message: 'Link points to folder, not file. Obsidian cannot preview folders.',
    suggestion: 'Link to a specific file or create an index.md'
  });
}

Impact

  • Severity: Medium - causes UX issues but has workaround
  • Frequency: Common in documentation structure
  • Detection: Silent failure (passes validation)

Related

  • Component: CitationValidator
  • Tool: citation-manager
  • Context: PostToolUse hook validation

Acceptance Criteria

  • Validator detects links pointing to directories (e.g., research/, ./docs/)
  • Folder links emit a warning (not error) with actionable suggestion
  • Warning message includes suggestion to link to specific file or create index.md
  • Non-folder links continue to validate without false warnings
  • Trailing slash and no-trailing-slash folder paths both detected

Definition of Done

  • Failing test written: folder link passes validation without warning (RED phase)
  • Fix implemented: directory detection added to validation pipeline (GREEN phase)
  • All existing citation-manager tests pass
  • Build succeeds: npm run build -w tools/citation-manager && npm link -w tools/citation-manager
  • Manual verification: folder link in test file emits warning
  • Committed with conventional commit message referencing this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions