How liustack/modlens works
ModLens is a vision plugin and CLI that turns pasted or referenced images into structured evidence and answers for text-only models. In DSH, the browser plugin captures pasted image bytes, the host side stores them as a private temporary file, and the CLI analyzes that image; alternatively, users can invoke the CLI directly with an image path or URL. The analyzer selects providers and fails over across built-in engines and reusable local CLIs. Auto-discovered routes, paste recovery, model guarding, and configuration/health commands are distinct supporting capabilities. Source excerpts are partial, so uncertain internal wiring is omitted.
Main entry points: main.ts ModLens CLI · analyzer.ts Image analyzer · providers Provider implementations · index.ts Provider registry
Components 20
Image intake
- Paste listener
dsh/client.js - Paste and tool routes
dsh/index.js - Paste recovery
src/recoverPaste/index.ts
Vision analysis
- ModLens CLI
src/main.ts - Image analyzer
src/analyzer.ts - Evidence prompt
src/prompt.ts
Vision engines
- Route discovery
src/auto/discover.ts - Borrowed routes
src/auto/routes.ts - Provider registry
src/providers/index.ts - Provider implementations
src/providers
Safety and setup
- Configuration
src/config.ts - Model guard
src/guard/index.ts - Remote image safety
src/net/network.ts - Health diagnostics
src/doctor.ts - Failover cooldown
src/cooldown.ts
Other components
- User
- DSH host
- Harness session stores
- Vision APIs
- Local vision CLIs
Connections 21
- User → Paste listener: pastes image
- Paste listener → Paste and tool routes: uploads bytes
- Paste and tool routes → DSH host: stores path
- DSH host → ModLens CLI: invokes read
- User → ModLens CLI: requests image read
- ModLens CLI → Configuration: loads settings
- ModLens CLI → Model guard: checks model
- ModLens CLI → Failover cooldown: builds cooldown
- ModLens CLI → Image analyzer: analyzes image
- Image analyzer → Evidence prompt: builds prompt
- Image analyzer → Provider registry: selects and runs
- Provider registry → Provider implementations: dispatches provider
- Provider implementations → Vision APIs: sends image request
- Provider implementations → Local vision CLIs: spawns vision CLI
- Image analyzer → Remote image safety: validates remote image
- Route discovery → Borrowed routes: supplies routes
- Borrowed routes → Provider registry: adds providers
- User → Paste recovery: requests recovered paste
- Paste recovery → Harness session stores: reads image records
- ModLens CLI → Health diagnostics: builds report
- Health diagnostics → Configuration: reads settings