Skip to content

Read Only Viewer

JanYork edited this page Aug 14, 2026 · 2 revisions

Read-only Viewer

Language: English · 简体中文

lwc view starts a local browser interface for inspecting one live Wiki. It is a foreground, loopback-only server that reads current state without migrating, refreshing, indexing, or mutating the project.

Use it to understand a Wiki visually. Use the CLI for every write, recovery, and acceptance workflow.

Start the Viewer

lwc --scope project view
lwc --scope project view --port 4173 --no-open

The default port is 0, so the operating system selects an available port. Startup prints JSON containing the URL, bound address, read_only=true, and whether LWC opened a browser.

Without --no-open, LWC tries the platform browser launcher. If that fails, open the printed URL manually. Press Ctrl+C in the launching terminal to stop the server.

Viewer is a live-Wiki command. It rejects --scope all and a changeset selector.

What the interface shows

Section Data shown Boundary
Overview Database path, revision, operation ID, Page and Source counts Current selected Wiki
Pages Page list and rendered Markdown body At most 1,000 listed Pages
Sources Source ID, title or origin, and byte count At most 1,000 listed Sources
Knowledge graph Links between canonical Wiki Pages At most 1,000 nodes and 5,000 edges
Code graph Nodes and edges from the project CodeGraph database Available only after lwc cg init; at most 1,000 nodes and 5,000 edges
Word graph Query-bounded term-to-document sample 25 documents and 30 terms per page

The Knowledge graph tab is the Wiki Page-link network. It is assembled from canonical Pages and [[wikilinks]]; it is not a dump of the external Grafeo/SurrealDB document graph.

The Code graph tab reads the existing project-local CodeGraph database in SQLite read-only mode. Viewer never downloads CodeGraph, runs cg init, or refreshes the index. If the index is unavailable, the tab reports how to initialize it outside Viewer.

Word graph is query-first

The Word graph starts empty. Enter up to eight searchable terms; LWC retrieves a bounded candidate page of documents and then derives only the terms and memberships inside that sample.

The browser requests 25 documents and 30 terms at a time and exposes Previous/Next pagination. The API clamps larger requests and reports truncation diagnostics. This design prevents dense token data from loading as one global graph.

See Word graph for tokenization, limits, and interpretation rules.

Interactive graph controls

Knowledge, code, and word graphs share one local 3D relationship view:

  • drag to rotate;
  • scroll to zoom;
  • labels remain attached to nodes;
  • higher-degree nodes receive stronger visual emphasis;
  • the footer reports visible node and edge counts and whether a bound truncated the view.

The visualization is for exploration, not a graph consistency check. Use the relevant CLI commands for exact nodes, paths, impact, Work, and verification.

Language behavior

Viewer starts in English. Use the 中文 / EN control to switch interface language. The choice is stored in browser local storage.

Only interface copy changes. LWC does not translate authored Page bodies, Source titles, identifiers, code symbols, or graph labels.

Read-only contract

Viewer:

  • binds only to 127.0.0.1;
  • exposes GET and HEAD routes; write methods receive HTTP 405;
  • opens Wiki and CodeGraph databases read-only;
  • never initializes or switches a graph engine;
  • never starts document-graph construction or CodeGraph indexing;
  • never refreshes historical Source revisions;
  • serves embedded JavaScript and CSS without a CDN or Node.js runtime;
  • sanitizes rendered Markdown and removes scripts, active embeds, images, inline style attributes, and style elements;
  • sends a restrictive Content Security Policy and nosniff headers.

Starting Viewer and reading every endpoint must leave durable project state unchanged. SQLite may maintain transient read-lock bookkeeping, but Viewer does not perform a canonical or derived write.

Local security boundary

Loopback binding prevents direct network exposure; it is not an authentication layer. Other processes running as the same host user may still reach the random local port while Viewer is active.

  • Do not proxy the URL to a public interface.
  • Do not run Viewer on an untrusted shared account.
  • Stop it after inspection.
  • Treat Page bodies, Source origins, code paths, and graph labels as potentially sensitive project data.

The server embeds all assets and sets frame-ancestors 'none', but browser extensions and local malware remain outside LWC's trust boundary.

API surface

Viewer uses these local read APIs:

GET /api/status
GET /api/pages?limit=1000&offset=0
GET /api/pages/{slug}
GET /api/sources?limit=1000&offset=0
GET /api/graphs/knowledge
GET /api/graphs/code
GET /api/graphs/words?query=...&limit=25&term_limit=30&offset=0

These endpoints are an implementation surface for the embedded UI, not a versioned remote integration API. Automation should prefer the stable lwc JSON CLI or read-only MCP tool.

Troubleshooting-and-FAQ

  • view_bind_failed: choose port 0 or another free loopback port.
  • Browser did not open: rerun with --no-open and use the printed URL.
  • Code graph unavailable: run lwc --scope project cg status, then initialize outside Viewer with explicit consent when needed.
  • Word graph rejects a query: provide one to eight searchable terms.
  • Graph looks truncated: use CLI graph exploration or the next Word graph sample instead of increasing the whole visualization without bounds.
  • Data looks stale: stop Viewer, repair or refresh through the appropriate CLI workflow, verify it, and start a new Viewer process.

Completion evidence

A Viewer inspection is complete when:

  • startup reports loopback URL and read_only=true;
  • the intended Page, Source, or bounded graph sample is visible;
  • unavailable graph capabilities remain disabled rather than being initialized implicitly;
  • CLI verification is used for any conclusion about correctness;
  • Ctrl+C stops the foreground server and closes the port;
  • durable Wiki and index state did not change because of Viewer requests.

LWC Wiki

English · 简体中文


Start here · 开始使用

Core capabilities · 核心能力

Practical guides · 实战指南

Capability configuration · 能力配置

Technical design · 技术设计

Operations · 运行与维护

Reference · 参考资料

Contributing · 参与贡献


Repository · Releases

Clone this wiki locally