A polished, Canadian-legal reader that helps users analyse a court or tribunal decision. Upload a judgment (PDF, DOCX, or plain text), and CaseLens:
.txt, .md).The full uploaded judgment stays central ā CaseLens never replaces it with a summary, and it never invents citations, parallel citations, history, or treatment. Anything it cannot confidently extract is shown as "Not detected".
server/analyze.ts) that works out of the box and is labelled in the UI.ANTHROPIC_API_KEY and the pipeline uses Claude for deep, structured extraction (server/ai.ts). CLAUDE_MODEL optionally overrides the default model.š Add ANTHROPIC_API_KEY here: https://www.val.town/x/justinstevens/caselens-canada/environment-variables?key=ANTHROPIC_API_KEY
When AI is enabled, every highlight is still anchored to a verbatim substring of the uploaded text; candidates that can't be anchored are dropped. If the AI call fails, the app transparently falls back to the heuristic engine.
server/text.ts segments the document into paragraphs (preserving numbers/headings) and extracts case metadata (best-effort, honest).exactQuote ā AI or heuristic.server/analyze.ts finds each quote as a character-exact substring, records startChar/endChar offsets, and dedupes overlapping spans (keeping the more important one).Rendering mermaid diagram...
index.ts ā Hono HTTP entrypoint; serves the SPA and /api/analyze.server/text.ts, server/analyze.ts, server/ai.ts ā the analysis pipeline.frontend/ ā React SPA (landing, progress, two-pane reader, export).frontend/demo.ts ā a clearly-labelled fictional sample judgment used by the "Try the sample judgment" button.types.ts ā shared types + the highlight legend (single source of truth for categories and colors).| Category | Meaning |
|---|---|
| Ratio / core holding | the binding principle the decision turns on |
| Legal test / rule | a test, standard, or governing rule |
| Application / reasoning | applying the law to the facts |
| Key factual finding | a fact the court relies on |
| Credibility finding | reliability / weight of evidence |
| Procedural ruling | jurisdiction, standing, admissibility, process |
| Remedy / disposition / order | the operative order |
| Notable obiter | persuasive, non-binding comment |
| Definition | definition or interpretation adopted |
Documents are parsed in the browser; only the extracted plain text is sent to CaseLens for analysis. No document is retained server-side.
CaseLens Canada analyses the text you upload only. It does not determine whether a case is still good law ā that requires a citator (e.g. keyCite/CanLII treatment checking) which is not connected. Use this tool to accelerate reading, not to replace your own research.
Every page links to this val's source at /source.
Run the pipeline standalone with server/selftest.ts.