feat(evangeliser): implement phases 1-5 — scanner, tests, CLI, 40 patterns#41
Conversation
…terns ReScript Evangeliser goes from 50% to ~90% completion: - Phase 1: Consolidate canonical/satellite, fix SPDX to PMPL-1.0-or-later, fix npx→Deno, update rescript.json for v12 deprecations - Phase 2: Scanner.res + Analyser.res with regex pattern detection engine, confidence scoring, coverage analysis, and difficulty assessment - Phase 3: 38 tests across 6 suites (Types, Glyphs, Narrative, Patterns, Scanner, Analyser) — all passing - Phase 4: Expand from 15 to 40 patterns covering all 21 categories (Destructuring, Variants, PipeOperator, StateMachines, DataModeling, etc.) - Phase 5: CLI with scan/patterns/legend/stats commands, RAW/FOLDED/GLYPHED views, plain/markdown/html output formats Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa81e791e1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| switch regex->RegExp.exec(code) { | ||
| | None => continue_ := false | ||
| | Some(result) => | ||
| let matchedText = result->RegExp.Result.input |
There was a problem hiding this comment.
Capture matched fragment, not the full source text
scanPattern assigns matchedText from RegExp.Result.input, which is the entire scanned file, so every patternMatch.code becomes the full source and startLine/endLine are computed from that full text instead of the actual regex hit. Any consumer relying on match snippets or line spans (including diagnostics and editor integrations) will receive incorrect locations for virtually all matches.
Useful? React with 👍 / 👎.
|
|
||
| // Compute coverage: what percentage of available categories were matched | ||
| let computeCoverage = (matches: array<patternMatch>): float => { | ||
| let totalCategories = 20 // from Types.patternCategory |
There was a problem hiding this comment.
Use the real pattern-category count for coverage
computeCoverage hard-codes totalCategories = 20, but Types.patternCategory defines 21 categories, so coverage is systematically inflated and can exceed 100% when all categories are matched. This makes the reported metric inaccurate for users and downstream reporting.
Useful? React with 👍 / 👎.
| | "patterns" => | ||
| Output.formatPatternList(opts.format) |
There was a problem hiding this comment.
Honor --difficulty when listing patterns
The CLI advertises and parses --difficulty (including the patterns --difficulty beginner example), but the patterns branch ignores opts.difficulty and always calls Output.formatPatternList(opts.format), so users cannot filter the list as documented. This is a functional mismatch between help text and command behavior.
Useful? React with 👍 / 👎.
Remove scripts/build.ts, clean.ts, validate.ts (TypeScript violates language policy). Build/clean now use `deno run -A npm:rescript` directly. Validation handled by justfile recipes. Update deno.json to remove stale references. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Scanner.res+Analyser.res— regex-based JS pattern detection engine with confidence scoring, coverage analysis, difficulty assessment, and pattern suggestionsscan/patterns/legend/statscommands, RAW/FOLDED/GLYPHED view layers, plain/markdown/html output formatsTest plan
deno run -A npm:rescript build— 0 errors, 0 warningsdeno run --allow-read --allow-env test/run_all.js— 38/38 tests passbin/evangeliser.js scan <file>— scans JS files, outputs narratives with glyphsbin/evangeliser.js patterns— lists all 40 patterns by categorybin/evangeliser.js stats— shows library statistics🤖 Generated with Claude Code