Skip to content

feat(view) add local directory origin adapter for views & cache operations#23

Merged
indexzero merged 2 commits intomainfrom
feat/local-origin-adapters
Feb 2, 2026
Merged

feat(view) add local directory origin adapter for views & cache operations#23
indexzero merged 2 commits intomainfrom
feat/local-origin-adapters

Conversation

@indexzero
Copy link
Owner

@indexzero indexzero commented Feb 2, 2026

  • LocalDirStorageDriver: mount local packument directories as read-only virtual caches

    • Implements storage driver interface (list, get, has)
    • Throws on write operations (put, delete, clear)
    • Handles file:// URLs and filesystem paths
    • isLocalPath() detects local vs registry origins
  • Storage driver factory: createStorageDriver({ LOCAL_DIR: path }) creates local dir driver

    • CACHE_DIR path unchanged for registry cache
    • LOCAL_DIR takes precedence when both specified
  • View query simplified: remove adapter abstraction, use cache directly

    • cache.keys(prefix) and cache.fetch(key) replace adapter layer
    • Driver selection moved to CLI where origin is known
    • origin-adapter.js deleted from view module
  • CLI usage: views with local registry field work transparently

    # Create view pointing to local directory
    _all_docs view create local-packages \
      --registry ./my-packuments \
      --select "name, version:=distTags.latest"
    
    # Query works same as registry-backed views
    _all_docs view query local-packages --limit 10

indexzero and others added 2 commits February 1, 2026 22:43
Add origin adapter abstraction to support querying packuments from
different sources:

- CacheAdapter: Wraps existing cache-based packument storage
- LocalDirAdapter: Reads JSON files from local directory
- createOriginAdapter: Factory auto-detects origin type

Views can now be defined over local directories using:
- Relative paths: ./local-data/
- Absolute paths: /data/npm-archive/
- file:// URLs: file:///path/to/dir/

This enables comparing npm cache against local snapshots,
archived data, or exported packument sets.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
LocalDirAdapter in src/view was reimplementing the storage driver
interface with different method names (keys/fetch vs list/get).
Moving it to src/cache as LocalDirStorageDriver:

- Implements proper storage driver interface (list, get, has)
- Read-only stubs for put, delete, clear
- createStorageDriver({ LOCAL_DIR: path }) creates the driver
- isLocalPath() exported for origin detection
- View query.js simplified to use cache directly
- CLI detects local paths and creates appropriate driver

This enables mounting local packument directories as virtual caches
for any cache consumer, not just views.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@indexzero indexzero merged commit 9fcff66 into main Feb 2, 2026
1 check passed
@indexzero indexzero deleted the feat/local-origin-adapters branch February 2, 2026 04:05
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