Skip to content

fix(lattice): normalize Windows path separators in section/ref file IDs#67

Open
RicardoAGL wants to merge 2 commits into
1st1:mainfrom
RicardoAGL:fix/windows-path-separators
Open

fix(lattice): normalize Windows path separators in section/ref file IDs#67
RicardoAGL wants to merge 2 commits into
1st1:mainfrom
RicardoAGL:fix/windows-path-separators

Conversation

@RicardoAGL

Copy link
Copy Markdown

Problem

On Windows, path.relative() returns backslash-separated paths (e.g. docs\api.md). These backslashes were embedded raw into the file field used for section IDs and ref resolution, causing wiki-link lookups to fail with false broken-link errors.

Example: a clean project on Windows produces 8+ spurious broken-link errors from lat check where all links are valid — the IDs just don't match because one side uses \ and the other uses /.

Fix

Chain .replace(/\/g, '/') after the .md strip in both parseSections() and extractRefs() in src/lattice.ts.

This is a no-op on Mac/Linuxpath.relative() already returns forward slashes on those platforms, so the extra replace has zero effect and introduces no risk.

Testing

Tested manually on Windows 11 with a project containing nested subdirectory markdown files:

  • Before: lat check reports 8 broken-link errors for valid links
  • After: lat check reports 0 errors (only the expected "no init version" advisory)

Scope

Only the two relative() calls that feed into the file variable (used for ID construction). The sectionFilePath field (display-only, retains .md) is intentionally left as-is since it is not used in link resolution.

On Windows, path.relative() returns backslash-separated paths.
These backslashes were embedded raw into section IDs and ref file
fields, causing wiki-link resolution to fail with false broken-link
errors on Windows (e.g. 8 spurious errors in a clean project).

Fix: chain .replace(/\/g, '/') after the .md strip in both
parseSections() and extractRefs(). This is a no-op on Mac/Linux
where relative() already returns forward slashes.

Fixes broken `lat check` output on Windows.
Adds `ollama:<model>` key format to LAT_LLM_KEY, enabling local
embedding generation via Ollama without an external API key.

Usage:
  LAT_LLM_KEY=ollama:nomic-embed-text lat search "query"

Environment variables:
  OLLAMA_HOST           Ollama base URL (default: http://localhost:11434)
  LAT_OLLAMA_DIMENSIONS Override vector dimensions for unlisted models

Known dimensions are pre-configured for: nomic-embed-text (768),
mxbai-embed-large (1024), all-minilm (384), snowflake-arctic-embed (1024),
bge-large (1024), bge-base (768), bge-small (384).

For any other model, set LAT_OLLAMA_DIMENSIONS to the model's output size.
The Ollama /v1/embeddings endpoint is OpenAI-compatible — no auth header
is sent (Ollama runs locally and requires none).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant