@wastech-mdlint/viewer 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +86 -2
- package/assets/favicon.ico +0 -0
- package/assets/viewer.css +4184 -0
- package/dist/asset-routes.d.ts +4 -0
- package/dist/asset-routes.js +107 -0
- package/dist/blame.d.ts +8 -0
- package/dist/blame.js +54 -0
- package/dist/branch-changes.d.ts +8 -0
- package/dist/branch-changes.js +49 -0
- package/dist/candidate-lint-worker.d.ts +1 -0
- package/dist/candidate-lint-worker.js +67 -0
- package/dist/candidate-lint.d.ts +39 -0
- package/dist/candidate-lint.js +115 -0
- package/dist/change-banner.d.ts +38 -0
- package/dist/change-banner.js +108 -0
- package/dist/change-diff.d.ts +23 -0
- package/dist/change-diff.js +140 -0
- package/dist/change-marks.d.ts +32 -0
- package/dist/change-marks.js +363 -0
- package/dist/changes-article.d.ts +15 -0
- package/dist/changes-article.js +244 -0
- package/dist/changes-routes.d.ts +12 -0
- package/dist/changes-routes.js +271 -0
- package/dist/changes.d.ts +113 -0
- package/dist/changes.js +324 -0
- package/dist/cli-args.d.ts +21 -0
- package/dist/cli-args.js +93 -0
- package/dist/client/banner-height.d.ts +1 -0
- package/dist/client/banner-height.js +33 -0
- package/dist/client/change-marks.d.ts +1 -0
- package/dist/client/change-marks.js +56 -0
- package/dist/client/changes.d.ts +1 -0
- package/dist/client/changes.js +183 -0
- package/dist/client/chart-option.d.ts +3 -0
- package/dist/client/chart-option.js +76 -0
- package/dist/client/charts.d.ts +1 -0
- package/dist/client/charts.js +54 -0
- package/dist/client/clipboard.d.ts +1 -0
- package/dist/client/clipboard.js +43 -0
- package/dist/client/code-copy.d.ts +1 -0
- package/dist/client/code-copy.js +29 -0
- package/dist/client/column-resize.d.ts +1 -0
- package/dist/client/column-resize.js +120 -0
- package/dist/client/config-dom.d.ts +13 -0
- package/dist/client/config-dom.js +47 -0
- package/dist/client/config-draft.d.ts +73 -0
- package/dist/client/config-draft.js +218 -0
- package/dist/client/config-editor.d.ts +3 -0
- package/dist/client/config-editor.js +677 -0
- package/dist/client/config-fields.d.ts +35 -0
- package/dist/client/config-fields.js +339 -0
- package/dist/client/config-json.d.ts +18 -0
- package/dist/client/config-json.js +96 -0
- package/dist/client/config-preview.d.ts +9 -0
- package/dist/client/config-preview.js +91 -0
- package/dist/client/config-rules.d.ts +14 -0
- package/dist/client/config-rules.js +202 -0
- package/dist/client/config-types.d.ts +91 -0
- package/dist/client/config-types.js +4 -0
- package/dist/client/copy-path.d.ts +1 -0
- package/dist/client/copy-path.js +32 -0
- package/dist/client/dashboard-requests.d.ts +11 -0
- package/dist/client/dashboard-requests.js +28 -0
- package/dist/client/dashboard.d.ts +1 -0
- package/dist/client/dashboard.js +119 -0
- package/dist/client/diagnostics.d.ts +1 -0
- package/dist/client/diagnostics.js +164 -0
- package/dist/client/diagrams.d.ts +1 -0
- package/dist/client/diagrams.js +81 -0
- package/dist/client/diff-expand.d.ts +1 -0
- package/dist/client/diff-expand.js +42 -0
- package/dist/client/display-settings-model.d.ts +74 -0
- package/dist/client/display-settings-model.js +229 -0
- package/dist/client/display-settings.d.ts +1 -0
- package/dist/client/display-settings.js +411 -0
- package/dist/client/echarts.d.ts +30 -0
- package/dist/client/echarts.js +14 -0
- package/dist/client/graph-layout.d.ts +88 -0
- package/dist/client/graph-layout.js +198 -0
- package/dist/client/graph.d.ts +2 -0
- package/dist/client/graph.js +566 -0
- package/dist/client/history.d.ts +21 -0
- package/dist/client/history.js +86 -0
- package/dist/client/live-reload-model.d.ts +28 -0
- package/dist/client/live-reload-model.js +52 -0
- package/dist/client/live-reload.d.ts +9 -0
- package/dist/client/live-reload.js +138 -0
- package/dist/client/menu.d.ts +14 -0
- package/dist/client/menu.js +176 -0
- package/dist/client/navigation-feedback.d.ts +1 -0
- package/dist/client/navigation-feedback.js +141 -0
- package/dist/client/open-config.d.ts +1 -0
- package/dist/client/open-config.js +48 -0
- package/dist/client/outline-spy.d.ts +1 -0
- package/dist/client/outline-spy.js +60 -0
- package/dist/client/prompts.d.ts +7 -0
- package/dist/client/prompts.js +65 -0
- package/dist/client/review.d.ts +1 -0
- package/dist/client/review.js +379 -0
- package/dist/client/search.d.ts +1 -0
- package/dist/client/search.js +199 -0
- package/dist/client/segmented.d.ts +13 -0
- package/dist/client/segmented.js +70 -0
- package/dist/client/source-lines.d.ts +16 -0
- package/dist/client/source-lines.js +47 -0
- package/dist/client/theme-toggle.d.ts +10 -0
- package/dist/client/theme-toggle.js +100 -0
- package/dist/client/theme.d.ts +0 -0
- package/dist/client/theme.js +50 -0
- package/dist/client/tree-marks.d.ts +31 -0
- package/dist/client/tree-marks.js +102 -0
- package/dist/client/tree-state.d.ts +0 -0
- package/dist/client/tree-state.js +179 -0
- package/dist/client/viewer.d.ts +1 -0
- package/dist/client/viewer.js +53 -0
- package/dist/config-editor.d.ts +166 -0
- package/dist/config-editor.js +378 -0
- package/dist/config-routes.d.ts +18 -0
- package/dist/config-routes.js +213 -0
- package/dist/context-view.d.ts +41 -0
- package/dist/context-view.js +295 -0
- package/dist/corpus-routes.d.ts +31 -0
- package/dist/corpus-routes.js +258 -0
- package/dist/corpus.d.ts +134 -0
- package/dist/corpus.js +653 -0
- package/dist/dashboard-article.d.ts +14 -0
- package/dist/dashboard-article.js +290 -0
- package/dist/dashboard.d.ts +94 -0
- package/dist/dashboard.js +468 -0
- package/dist/diagnostics.d.ts +23 -0
- package/dist/diagnostics.js +44 -0
- package/dist/document-routes.d.ts +39 -0
- package/dist/document-routes.js +396 -0
- package/dist/event-hub.d.ts +39 -0
- package/dist/event-hub.js +120 -0
- package/dist/findings-panel.d.ts +4 -0
- package/dist/findings-panel.js +74 -0
- package/dist/folder-page.d.ts +8 -0
- package/dist/folder-page.js +74 -0
- package/dist/graph-view.d.ts +66 -0
- package/dist/graph-view.js +236 -0
- package/dist/highlight.d.ts +24 -0
- package/dist/highlight.js +100 -0
- package/dist/http-send.d.ts +9 -0
- package/dist/http-send.js +53 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +72 -0
- package/dist/open-file.d.ts +36 -0
- package/dist/open-file.js +87 -0
- package/dist/page-tree.d.ts +3 -0
- package/dist/page-tree.js +105 -0
- package/dist/page.d.ts +73 -0
- package/dist/page.js +478 -0
- package/dist/prompts.d.ts +25 -0
- package/dist/prompts.js +82 -0
- package/dist/render-cache.d.ts +23 -0
- package/dist/render-cache.js +38 -0
- package/dist/render-document.d.ts +60 -0
- package/dist/render-document.js +440 -0
- package/dist/request-path.d.ts +17 -0
- package/dist/request-path.js +51 -0
- package/dist/review-context.d.ts +24 -0
- package/dist/review-context.js +109 -0
- package/dist/review-queries.d.ts +26 -0
- package/dist/review-queries.js +69 -0
- package/dist/review-state.d.ts +106 -0
- package/dist/review-state.js +251 -0
- package/dist/review-store.d.ts +145 -0
- package/dist/review-store.js +530 -0
- package/dist/router.d.ts +28 -0
- package/dist/router.js +294 -0
- package/dist/search.d.ts +22 -0
- package/dist/search.js +164 -0
- package/dist/security.d.ts +95 -0
- package/dist/security.js +196 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.js +224 -0
- package/dist/speculation-rules.d.ts +4 -0
- package/dist/speculation-rules.js +49 -0
- package/dist/state-dir.d.ts +6 -0
- package/dist/state-dir.js +31 -0
- package/dist/tree-marks.d.ts +49 -0
- package/dist/tree-marks.js +108 -0
- package/dist/viewer-context.d.ts +37 -0
- package/dist/viewer-context.js +74 -0
- package/dist/watch.d.ts +41 -0
- package/dist/watch.js +135 -0
- package/package.json +57 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vladimir Makarevich
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @wastech-mdlint/viewer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A local web viewer for a repository's Markdown. It serves exactly the corpus [wastech-mdlint](https://github.com/VladimirMakarevich/wastech-mdlint#readme) lints, as pages with the document tree, highlighted code, Mermaid diagrams, ECharts charts, an outline, backlinks, a graph of the links between documents, full-text search, the linter's findings with prompts to fix them, a dashboard of the whole corpus and a review of what the current branch changed in it, lets the linter's config be edited with a preview of what it would report, lets the reader set the fonts, sizes and margins of the text, and reloads an open page when its file changes.
|
|
4
|
+
|
|
5
|
+
**Experimental.** Pages, options and the JSON routes may still change between minor versions. It is released together with [`@wastech-mdlint/core`](https://github.com/VladimirMakarevich/wastech-mdlint/blob/main/packages/core/README.md) and the CLI, at the same version, from one tag.
|
|
6
|
+
|
|
7
|
+
## Run it
|
|
8
|
+
|
|
9
|
+
Requires Node.js `24.17.0` or later.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @wastech-mdlint/viewer path/to/repository # run directly, no install
|
|
13
|
+
npm i -D @wastech-mdlint/viewer # or install the wastech-mdlint-viewer bin
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
From a checkout of this repository, after `npm run build`: `node packages/viewer/dist/index.js path/to/repository`.
|
|
17
|
+
|
|
18
|
+
It prints the address, by default `http://127.0.0.1:4180/`. The root opens the repository's `README.md`. Ctrl+C stops it once the git and lint work already running has finished; a second Ctrl+C quits at once.
|
|
19
|
+
|
|
20
|
+
| Option | Meaning |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| `[path]` | Repository directory; the current directory when omitted. |
|
|
23
|
+
| `-p, --port <n>` | Port. Without it the viewer takes `4180`, or the next free port above it. `0` picks any free port. |
|
|
24
|
+
| `--host <host>` | Address to bind. The default `127.0.0.1` keeps the documents on this machine; any other address lets the network read them, and the viewer says so when it starts. |
|
|
25
|
+
| `-c, --config <file>` | The `wastech-mdlint.config.json` to use instead of the one found in the repository. |
|
|
26
|
+
| `--no-watch` | Do not watch files or reload pages. |
|
|
27
|
+
| `--allow-config-writes` | Let the config page save changes to the config file. Off by default, and refused together with a `--host` that is not a loopback address. |
|
|
28
|
+
| `--base <ref>` | The branch, tag or commit the Changes section compares with. Without it: the branch `origin/HEAD` names, then `main`, then `master`. A name that matches nothing is reported when the viewer starts, which then serves everything else as usual. |
|
|
29
|
+
| `--state-dir <dir>` | Where review marks are kept. Without it: `%LOCALAPPDATA%\wastech-mdlint\viewer` on Windows, `~/Library/Application Support/wastech-mdlint/viewer` on macOS, `$XDG_STATE_HOME/wastech-mdlint/viewer` (or `~/.local/state/wastech-mdlint/viewer`) elsewhere. Inside, one folder per clone, named after it and shared by all its worktrees; deleting that folder clears its marks. |
|
|
30
|
+
|
|
31
|
+
## What it shows
|
|
32
|
+
|
|
33
|
+
- **The linted corpus.** The config's `include`, `exclude` and `respectGitignore` decide which files are documents, the same way `wastech-mdlint lint` decides, including dot-directories such as `.claude/` when the config includes them. Without a config, every Markdown file outside the default excludes.
|
|
34
|
+
- **Links that agree with the linter.** A relative or root-relative link resolves the way REF-001 resolves it, and heading ids are the slugs REF-002 checks anchors against, so a link the linter accepts works on the page. Links and images written as raw HTML (`<a href>`, `<img src>`) resolve the same way. A link to a folder opens that folder's `README.md`, or, when it has none, a listing of the documents under it. A link whose target does not exist, or is not served (see below), is underlined in red.
|
|
35
|
+
- **Linked source files.** A link from a document to a non-Markdown file opens it as highlighted source with line numbers; `#L42` and GitHub's `#L12-L20` ranges land on and mark those lines. Images a document embeds are served as they are. A file that an `exclude` pattern or a `.gitignore` covers is not served — every `.gitignore` counts here, whatever `respectGitignore` says, since it is where a repository names what it keeps to itself — and neither is a Markdown file outside the corpus.
|
|
36
|
+
- **Code and diagrams.** Fenced code is highlighted on the server with Shiki in light and dark themes, and every highlighted block — in a document, a linked source file or the config page — has a **Copy** button in its corner, shown on hover, that copies its code without the line numbers. A `mermaid` block is drawn in the browser; if it cannot be drawn, its source stays on the page with the reason.
|
|
37
|
+
- **Charts.** An `echarts` block holds an [ECharts option](https://echarts.apache.org/en/option.html) written as JSON — strict JSON, so no functions, comments or unquoted keys — and is drawn in the browser in the page's theme. A block that is not a JSON object says why above its source, with or without script. Tooltips are drawn as text on the chart, so markup in a `formatter` shows as written rather than as HTML, while `<br/>` still breaks the line.
|
|
38
|
+
- **Link graph.** `Graph` in the header opens every document as a node and every linked pair as a line, from the same context graph `wastech-mdlint graph` reports; hovering a document lights its links and names its neighbors without dimming the rest. Documents are laid out several node widths apart, the much-linked ones with room in proportion to their size so that none lands on another, and a large graph opens zoomed out to fit; only the most linked-to documents are named until the wheel zooms in far enough, and then the other names grow in. The folder picker narrows it to one folder and colors that folder's subfolders apart; dragging pans, a click opens the document. Opened from a document, the graph centers on it, draws its own links as arrows in the accent color, and turns every document outside its direct neighbors gray. A save that changes a link redraws it. In a git work tree, **Show the branch's changes** (`?changes=1`) rings each changed document in its letter's color and every unchanged one the change reaches in a dashed ring, draws the pairs the branch linked in green and the ones it unlinked as dashed red lines that pull nothing together, and the small graph beside a changed document does the same while its page shows its changes. Without script, the page lists the documents in view, changed ones with their letter, and the same data is at `/api/graph?folder=…&focus=…&changes=1`.
|
|
39
|
+
- **Copying a path.** The button beside the path in the header, and beside the config file on the config page, copies the path relative to the repository, as links and findings name it, or the absolute path on this machine. The absolute path is offered only when the viewer is bound to a loopback address.
|
|
40
|
+
- **Source lines.** Beside every block and list item, in the right margin, the line it starts on in the Markdown file, counted from the top with front matter included — the line an editor and a finding name. Selecting and copying the article leaves the numbers out, and they are hidden on a narrow screen and in print.
|
|
41
|
+
- **Front matter** as a card above the article, an **outline** of the document's `h2` and `h3` headings that marks the section being read as the page scrolls, and **backlinks**: the documents that link to this one, from the context graph.
|
|
42
|
+
- **Local graph.** Above the outline, a small graph of the document, the documents it links to and the ones linking to it, with the links among them (`/api/neighbors?path=…`). The neighbors sit evenly on a ring around the document, its own links drawn as fine arrows and the ones among them fainter still; a document with many neighbors opens zoomed out. It is drawn where it comes to rest rather than settling in view; only around a document with more than 120 neighbors does it still settle as you watch. Dragging pans it and Ctrl or ⌘ with the wheel, or a trackpad pinch, zooms it, while the plain wheel keeps scrolling the page. A click on a neighbor opens it, and a link below opens the full graph centered on the document. It is drawn only where the side column shows, so a narrow screen never loads it.
|
|
43
|
+
- **Search.** The box in the header searches titles, headings, paths and text, Cyrillic included, and matches a word while it is still being typed. `Ctrl+K` (or `/`) focuses it, the arrow keys pick a result and `Enter` opens it at the heading nearest the match. Without script, the same box opens a results page.
|
|
44
|
+
- **Lint findings.** The config's rules run over the corpus in the background. A document with findings shows them in a panel above its text — severity, rule, message and the heading to jump to — and the tree shows a count beside every file that has any. Both are drawn with the page once the first lint is in, and refresh on their own after each save.
|
|
45
|
+
- **Fix prompts.** Each finding in the panel has a **Prompt** menu, and so do the panel for all of the document's findings and every dashboard row with findings. It copies a prompt to hand to a coding agent. A size finding (SIZE-001, or LLM-001's context budget) offers three: compress the text without losing a fact, split the file by meaning, or raise the budget for that one path — the last spells out the config edit, including that SIZE-001 uses the first matching override and that a metric it leaves out falls back to the top-level budget. Any other finding offers a prompt to fix it in the document rather than silence it. The prompts follow the same policy as the agent rule `wastech-mdlint init` writes, name the config and the command that runs the linter in this repository, and are written from the latest lint run when the menu opens.
|
|
46
|
+
- **Dashboard.** `Dashboard` in the header lists every document with its errors, warnings and the rules behind them, its size in KB, lines and tokens (the counts SIZE-001 checks), how many documents link to it and how many it links to, and whether it is an orphan (nothing links to it), a dead end (it links nowhere), on a link cycle (as GRP-001 sees them) or outside the main group of linked documents. The filters pick documents with errors and/or warnings, from chosen rules (a severity and a rule are judged on the same finding), within a size, line or token range (both bounds included, a KB being 1024 bytes), with chosen link flags, in a folder, or with a text in the path; a column header sorts by that column. It works as a plain form without script; with script every change applies as it is made, and findings and sizes follow each save. The address carries the filters, `/api/dashboard?…` answers the same query as JSON, and the download links give the selection as CSV or JSON. In a git work tree a Branch column shows each document's letter when the branch changed it and the findings the change gave it and took from it, an unchanged document included, and **Changed in this branch** (`changed=1`) keeps only the changed ones; both are in the CSV and JSON. A switch above the tree shows only the files with findings.
|
|
47
|
+
- **Changes.** In a git work tree, `Changes` in the header reviews what the current branch changed in the corpus, against where it left the base branch (the merge-base, as GitHub compares a pull request), so commits that landed on the base afterwards never show as changes here. Only the linted documents are listed, however many other files the branch touched: the config file first when it changed, then the documents loaded into every agent session (LLM-001's entrypoints and everything they import, marked _every session_), then the rest by how many documents reach them through links, most first. Each has its diff, with the changed words of a paragraph marked inside the line, and in a table row the changed cell, whatever padding a formatter realigned around it; a line moved elsewhere is tinted apart and says where it went (`moved to line 42`), and the line it became where it came from; with script, the unchanged lines between hunks open twenty at a time; a long diff starts folded. Markdown files the config leaves out are counted above the list, so a narrowed scope never reads as no changes. Below the comparison it says what the change does to the context: the findings it adds and removes — the base linted as the merge-base held every document, a finding moved by an edit above it, or surviving an edit to its own line, counted as the same finding — and, for every LLM-001 entrypoint whose session context moved, its total against the budget (`CLAUDE.md eager context 8921 → 10.7k tokens (+1856, budget 10k)`; a count from ten thousand up in thousands, cut down rather than rounded, so a total just under its budget never reads as the budget), in the warning color when over it. Each row of the list shows its findings, a document given new errors moves up after the ones every session loads, and each card shows its document's tokens, lines and KB before and after, the findings it gained and lost, and the links it made and broke. **Affected documents** lists the documents the branch did not change that it still reaches: those with new findings — a heading renamed elsewhere broke their anchor, an entrypoint's imports grew — those whose `file.ts#L12-L20` link now points at code lines the branch edited or moved, and, folded, those that link to a changed document. When the config changed, its card adds what the config change alone does to the current documents' findings, through the same comparison the config page's preview uses. With **Commits only** the context is compared up to the last commit too, the uncommitted edits left out. **Work tree** includes uncommitted and untracked files; **Commits only** compares up to the last commit (`?worktree=0`). The header shows how many documents changed, the tree marks each with a letter — A, M, R — and a switch shows only those, and a changed document's page shows its changes in place (below). `/api/changes` lists the same as JSON, every finding in full, and `/api/changes/diff?path=…` gives one document's diff. Outside a git work tree, or without `git` on the path, there is no Changes section; when it cannot compare — no base branch, a shallow clone, a repository git refuses to read — the page says why and how to fix it.
|
|
48
|
+
- **Changes on a document's page.** Above a changed document's text, a line says what the branch did to it — its letter, the lines added and removed, a link to its card on the Changes page — and switches between three views, kept in the address so a reload or a shared link shows the same one. **Rendered** marks each changed block with a bar at its left edge, amber where it was edited and green where it is new: the innermost block only, so an edited list item is marked and not its list, while a table, a code block and the front matter card are each marked whole. Each block the branch removed is put back where it stood, folded (`2 blocks removed`), its links resolved against the current documents, so a link that only worked before the change shows as missing; with script, a click on a bar opens that block's hunks from the source diff below it. The outline marks every section that holds a change, and lists the text before the first section first, as **Introduction**, when the branch changed it. With script, **History** in that line lists the last commits that touched the document — short hash, date, author and subject — asked of git only when opened; a document the branch did not change has the same **History** above its text, on its own. **Source** (`?diff=source`) shows the document's diff in place of its text, and **Off** (`?diff=off`) the page without marks. A document the branch added gets the line but no marks, since every block would carry one. All of it is rendered on the server, so it reads the same without script; in print the bars stay as a left border and the removed blocks are left out.
|
|
49
|
+
- **Review marks.** In a git work tree, every card on the Changes page and the line above a changed document have a **Viewed** box; `v` checks or clears it — on the Changes page for the card being read. A mark records the text the page showed, not a time or a commit: the document stays reviewed while its text is that text — on another branch, after a rebase, a restart or a rename without edits — and turns **Changed since review** the moment it differs. A reviewed card folds to its header. The header's Changes count becomes what is left (`3/12`), the tree puts a dot beside every changed file not yet reviewed (amber once it changed since its review) and **Only files left to review** shows only those, and `n` and `p` open the next and previous one in the Changes page's order. **Compare with: My last review** (`?since=review`) shows, on the Changes page and in each view of a document's page, what changed since the version last reviewed; a document never reviewed, or whose reviewed text is no longer kept, is compared with the base branch, and the card says so. **Reset review** forgets the marks of every document listed, earlier versions included. Each second- and third-level section of a changed document has its own box in the outline: a section stays viewed while its own text is the text that was viewed, however the rest of the document moved on, and a document counts as reviewed once every section is — the text before the first section included, which the outline lists first as **Introduction**. While some of a document's sections are viewed and some are not, its card says how far the review has got (`2 of 5 sections`). Marking a document marks its sections as they are; a renamed heading is a new section. `/api/changes` gives each document's status, the hash a mark names and how many of its sections are viewed (`sections: { reviewed, total }`), and `/api/changes/diff?path=…&since=review` the diff since the review. There are no marks outside a git work tree, or with a `--host` that is not a loopback address.
|
|
50
|
+
- **Blame.** In a git work tree, **Blame** beside the path in the header (`?blame=1`) puts beside each block's source line number the commit that last touched any of its lines — short hash and date, or `uncommitted` — with the author and subject on hover; it combines with every view of a changed document. `/api/history?path=…` lists a document's last commits as JSON.
|
|
51
|
+
- **Config.** `Config` in the header shows the config file and every rule in the registry with its description. **Show in folder** opens the system's file manager with the file selected (on Linux, the folder that holds it), and **Open in default app** opens it in the application the system uses for it; both only when the viewer is bound to a loopback address. With script, a form built from the config schema edits the files, the rules — adding one from the registry, removing one, its severity and options — custom rules, settings and compile options; a Text view edits the file as a whole. The form comes with the page: what it is built from is carried in the page, and the page is drawn once the form is built, so the file and the rules below it never move down after it appears. A setting with two or three choices, such as a rule's severity or `respectGitignore`, is a row of segments, one click to change; a longer list is a menu. Each change is checked by the linter's own config loader, and the preview says what the change would report: the findings it adds and removes, per rule and one by one, or the loader's reason when the config would not load. The changed file can be copied or downloaded, or saved when the viewer was started with `--allow-config-writes`. Only the edited values change in the file: every comment and the layout of the rest stay as written. A preview that changes only rules takes a fraction of a second; one that changes `include`, `exclude` or `respectGitignore` reads the corpus again, as at startup. The preview lints on a thread of its own and is stopped after 15 seconds, so a custom rule pattern that backtracks without end, such as a half-typed `(a+)+$`, is reported in the preview instead of freezing every open page. With a `--host` that is not a loopback address the page is read-only: it shows the file and the rules and says why there is no editor.
|
|
52
|
+
- **Live reload.** Saving a document reloads the pages showing it and keeps the scroll position. A new or deleted document, a folder of documents moved, renamed or deleted, or a change to the config (under any name `--config` gives it) or a `.gitignore`, refreshes the tree on every open page. An image or file appearing or disappearing where a document links reloads that document's pages. A Markdown file the config leaves out changes nothing.
|
|
53
|
+
|
|
54
|
+
The header stays put when moving between pages: Graph, Dashboard, Changes (in a git work tree) and Config are one segmented control, every page renders the same bar with only the current section chosen, and every page arrives whole: the tree's counts, letters and dots, the Changes count and a document's findings are drawn into it, a tree narrowed by one of its switches is narrowed before it shows, and the controls that need script keep their room from the first frame, so nothing appears or moves a moment after a page is drawn. In browsers with cross-document view transitions the bar and the tree show the new page at once, and the article and the side column fade in over about a tenth of a second, from partly visible, with nothing of the old page under them. The stylesheet and the scripts are asked for on every page but sent again only when they changed. In Chrome and Edge a link to a document, and each of the header's sections, is fetched as the pointer rests on it for a moment, or as it is pressed, so the click is answered from that copy instead of waiting for the server (the rules are at `/speculation-rules.json`); the Blame switch, which has git blame every line, is not fetched ahead. A click answers at once with where it leads: the header's section the next page belongs to is chosen and the file it opens is marked in the tree before the page is left, and when the server keeps it waiting more than a fifth of a second, a thin bar grows under the header and the pointer shows it is busy. The Changes page and the dashboard, the longest pages, are drawn once their first screen has been read, the diffs and rows below it following out of sight. The tab shows the viewer's own icon.
|
|
55
|
+
|
|
56
|
+
On a phone the header wraps into three rows — the name with the theme and settings, the sections, the search box — and scrolls away with the page, and the document tree folds behind a **Documents** row above the article, closed on every page so a page opens on its text. Without script the tree stays open.
|
|
57
|
+
|
|
58
|
+
**Aa** at the right end of the header opens the display settings: the fonts of the whole site — header, tree, side column, panels and dashboard (system, serif, a wide sans, monospace, or any installed font by name) and a monospace font for paths and code — then the article's own text and code fonts, which follow the site's until changed, the text and code sizes, line height, the spacing between letters (code keeps its own), the space between blocks, left or justified text, the article's width or filling the column, the margins on all four sides, and the source line numbers. Each change applies as it is made, and Reset restores the defaults. A phone keeps its own narrow margins.
|
|
59
|
+
|
|
60
|
+
The theme switch in the header is three segments — Auto (follow the operating system), Light and Dark — chosen with a click or the arrow keys, and the choice is remembered for this address. So are the display settings, applied before the page is drawn so it never shows the defaults first, and the widths of the two side columns, the document tree and the rail with the local graph, outline and backlinks: hovering a column's edge toward the article shows a handle to drag (or focus it and use the arrow keys), a double click on the handle restores that column's default width, and the article always keeps room between them.
|
|
61
|
+
|
|
62
|
+
## Security
|
|
63
|
+
|
|
64
|
+
The viewer is bound to `127.0.0.1` unless `--host` says otherwise, writes nothing to the repository unless it was started with `--allow-config-writes`, and outside it writes only review marks, in the state directory. Because any web page in the same browser can make requests to it:
|
|
65
|
+
|
|
66
|
+
- it answers only requests addressed to localhost, an IP address or the configured host, which defeats DNS rebinding, and refuses requests from other origins;
|
|
67
|
+
- it serves documents in the corpus and only the files those documents link to or embed that no `exclude` pattern or `.gitignore` covers, so a request cannot read an arbitrary file by naming it, and a link to a local `.env` does not hand it out; paths that could climb out of the repository are refused before any lookup, and symlinks that lead outside it are not followed; the file a link really reaches is checked too — a symlink to an ignored file is not served, nor a path that reaches a file only under another letter case (`.GIT/config`, `.ENV`) on a case-insensitive file system — and the check is made again each time a file is served;
|
|
68
|
+
- raw HTML in Markdown is sanitized with GitHub's allowlist, keeping an author's `name` attribute on links only, where it cannot shadow what the page's scripts read from `document`; every page carries a Content-Security-Policy that allows scripts from the viewer only, and images (SVG included) are served sandboxed;
|
|
69
|
+
- a chart option is data: it is parsed as JSON and never evaluated, every tooltip in it is drawn as text, the data view's labels (which ECharts would insert as HTML) are dropped, and a `link` or `sublink` survives only as an `http(s)` URL;
|
|
70
|
+
- the config page's preview, save and open, and a review mark, are the only requests with a body, and with a `--host` that is not a loopback address every one of them is refused and no page carries the token: a preview lints the repository under a config the request sends, which could otherwise read any file in the checkout back through a custom rule's findings. On a loopback binding each must come from the viewer's own page — its origin, a JSON body and a random token only the config page, the Changes page and a changed document's page carry — and a save writes only the config file the corpus was loaded from, inside the repository, over the version the page saw, after the linter's loader has accepted the new text; it is written atomically and read back, and if another program wrote the file in the same moment, that program's version stays and the page says so;
|
|
71
|
+
- a review mark is accepted only for the version of a changed document the page showed, and only on a loopback binding, since it records this user's review; it is kept with the text reviewed in the clone's folder of the state directory, which only this user can read, written atomically under a lock every viewer of the clone takes, and a write that fails is reported with the earlier marks left whole. Reading a page creates nothing there;
|
|
72
|
+
- opening the config starts the system's own program (Explorer, `open` or `xdg-open`) for that file alone, found on `PATH` and started by its full path so a same-named file in the repository never runs, from an argument list rather than a shell command, and is refused, like saving, when `--host` is not a loopback address, since it would start a program on this machine for someone on another;
|
|
73
|
+
- absolute paths appear only on the copy-path button, and only when the viewer is bound to a loopback address, so a viewer reachable from the network does not say where the checkout lives;
|
|
74
|
+
- the Changes section, and a document's page to learn whether its document changed, run `git` with an argument list, by the absolute path `PATH` gives it — never a `git` committed to the repository, which Windows would otherwise find first — and only to read: it never writes under `.git` — the work tree is compared through `git status`, as a plain `git diff` would refresh and rewrite the index — never fetches an object a partial clone is missing, and it keeps the repository's own git config from starting any program, by turning off its fsmonitor hook, emptying every filter driver and passing `--no-ext-diff --no-textconv`; a `--base` that starts with `-` is refused before git sees it;
|
|
75
|
+
- nothing is fetched from the network: Mermaid, ECharts and the page assets come from the installed packages.
|
|
76
|
+
|
|
77
|
+
## Known limits
|
|
78
|
+
|
|
79
|
+
- Startup loads and parses the whole corpus, as `wastech-mdlint lint` does: about eight seconds for six hundred documents. After that an edit to a document is applied, re-linted and re-indexed in well under a second; adding or removing a document reloads the corpus.
|
|
80
|
+
- The search index is built on the first search (about a second for six hundred documents) and kept in memory.
|
|
81
|
+
- The graph is laid out in the browser, every node against every other. Six hundred documents and three thousand links take about a tenth of a second to draw and then settle smoothly; on a corpus many times larger, narrow the graph to a folder.
|
|
82
|
+
- The theme, the display settings and the column widths are kept by the browser for the viewer's address. A viewer that starts on another port (the default port was taken, or `--port` differs) opens with the defaults.
|
|
83
|
+
- The Changes section notices an edit through the same watcher as the pages, and a commit, a checkout, a reset or a fetch through a second watcher on git's `HEAD` and refs: the Changes page, a changed document's page and a graph or dashboard showing the branch reload when the comparison really moved, and every page's count follows; another branch's ref moving reloads nothing. While both watchers run, the review is kept between requests without asking git whether it is still current; should the watch on git's refs end — git can rewrite a folder it watched — every request asks again. Every page but a changed document's draws the tree's letters and the Changes count from the review last computed rather than wait for git, and the events that follow keep them current. With `--no-watch` neither watcher runs, an edit to the work tree shows only after a restart and a move of `HEAD` on the next request, which is also when a page's script asks for the letters and the count, as it opens. A Markdown file kept in git-lfs compares as its pointer text, since no filter driver is run.
|
|
84
|
+
- The context of a change is computed from both versions of the documents, but two things are read as they are now: a link to a file that is not a document resolves against the files on disk on both sides, since the linter needs a real directory to look in, so a link to a code file the branch deleted reads as fine at the base; and when the config's include, exclude or respectGitignore changed, the base is still read as the documents the current config selects. The Changes page says so when it applies. Linting both versions takes a fraction of a second once per change, kept until the next one, and is done as soon as the change is seen rather than when a page first asks.
|
|
85
|
+
- In a git work tree a document's page is sent once the review says whether its document changed: the kept one, and after a save the rebuilt review, a fraction of a second on a branch with a dozen changed documents. A page asked for during that rebuild waits for it rather than starting another. The changed words inside a paragraph are marked only in the Source view and on the Changes page; the rendered page marks whole blocks.
|
|
86
|
+
- A review mark covers a whole document, so an edit anywhere in it makes it changed since review, and each path remembers its last ten reviewed versions. Marks are kept under the clone's git directory's location, so a clone moved to another folder, or cloned afresh, starts with none. With **My last review** the diffs compare with the reviewed version, while a card's sizes and findings still compare with the base branch. Blame and history are read from git on every request, without a cache: a fraction of a second on a document with a short history, longer on one git has to follow through many commits. Author names appear only on a loopback binding, as absolute paths do.
|
|
87
|
+
- On Linux, Node watches a directory tree with one inotify watch per directory, so a very large `node_modules` inside the repository can exhaust the watch limit. Run with `--no-watch` there, or raise `fs.inotify.max_user_watches`.
|
|
Binary file
|