Skip to content

Add LOCAL_DATA_DIR: filesystem-based manifest indexing - #2

Merged
tz8 merged 1 commit into
mainfrom
feature/local-fs-manifest
Jul 10, 2026
Merged

tz8 merged 1 commit into
mainfrom
feature/local-fs-manifest

Conversation

@tz8

@tz8 tz8 commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #1. LOCAL_BASE_URL only replaced content fetching — manifest indexing (directory listing) still hit the GitHub Contents API, which is rate-limited to 60/hr unauthenticated and was failing for anyone running the server without a GITHUB_TOKEN.

  • New LOCAL_DATA_DIR env var: when set, both indexing and content fetching read directly from a local data/ directory on disk (fs.readdir + file:// URLs), no GitHub calls at all for core content.
  • LOCAL_BASE_URL is ignored when LOCAL_DATA_DIR is set.
  • Homebrew indexing is unchanged (GitHub-only, self-hosted mirrors do not bundle it) — already degrades gracefully on rate-limit errors.
  • Falls back to the existing GitHub-based path when LOCAL_DATA_DIR is unset, so stdio/Claude Desktop users are unaffected.

Testing

  • New unit tests: tests/manifest/local-builder.test.ts (5), file:// coverage in tests/github.test.ts (2). Full suite: 440 tests, lint/typecheck/build clean.
  • Verified end-to-end against a real fixture data/ directory over the HTTP transport: returned exactly the fixture content with zero GitHub calls in the log.

- New src/manifest/local-builder.ts: scans a local 5etools data/
  directory directly via fs.readdir instead of the GitHub Contents
  API. Uses file mtime+size as a cache-invalidation key in place of
  a GitHub blob SHA.
- github.ts fetchRaw() now handles file:// URLs by reading straight
  from disk, so content fetching is fully network-free too when
  LOCAL_DATA_DIR is set (LOCAL_BASE_URL is then ignored).
- builder.ts: buildManifest() branches on LOCAL_DATA_DIR; falls back
  to the existing GitHub-based path when unset, so stdio/Claude
  Desktop users are unaffected.
- Homebrew indexing is unchanged (still GitHub-only, already
  non-fatal on rate-limit errors) — self-hosted mirrors don't bundle
  third-party homebrew content.
- Tests: tests/manifest/local-builder.test.ts (5 tests) and file://
  coverage added to tests/github.test.ts (2 tests). Full suite: 440
  tests, lint/typecheck/build all clean.
- Verified end-to-end against a real fixture data/ directory: served
  correct, fixture-only content with zero GitHub calls.
@tz8
tz8 merged commit 370f1db into main Jul 10, 2026
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