-
Notifications
You must be signed in to change notification settings - Fork 62
Hazel CLI LSP #2056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
disconcision
wants to merge
46
commits into
probe-III
Choose a base branch
from
hazel-lsp-cli
base: probe-III
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Hazel CLI LSP #2056
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLI implementation (src/CLI/): - Rust-style error formatting with source context, line numbers, carets - evaluate_with_probe_map for probe sample collection - All commands working: run, format, analyze, probe (with --many) Documentation (plans/hazel-lsp-cli/): - cli-api.md: Complete CLI reference with examples - hazel-primer.md: Comprehensive Hazel syntax guide - hazel-builtins.md: Full builtin list with OCaml/ReasonML differences - vision.md: Long-term direction (semantic views, structural queries) - experience-log.md: AI experience tracking workflow - README.md: Project plan with status tracking Sample programs (hazel-programs/): - 9 documentation programs extracted from ML slides - 39 B2T2 programs extracted from ML slides - Folder structure for study tasks and examples Utilities (scripts/): - extract-docs.py: Extract .hz programs from ML backup_text fields 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
CLI test command (src/CLI/): - ./hazel test runs tests and reports pass/fail with line numbers - Shows hint strings for named tests (hint "name" test ... end) - Supports --verbose flag to show all tests - Exit code 0 = pass, 124 = failures Study program infrastructure (plans/study-programs.md): - Requirements for probe debugging user study programs - Development process and bug design guidelines - Tiered list of program concepts ready for parallel implementation - Probe mechanism overview from codebase research Example programs: - emojipaint.hz: Working version with comprehensive tests - emojipaint-bug.hz: Buggy version with single failing test - Proper indentation applied to both Documentation updates: - cli-api.md: Full test command documentation - hazel-primer.md: Named tests, debugging workflow with probes - README.md: Updated status and TODOs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Three new programs for probe debugging user studies: Tic-Tac-Toe (~265 lines, 18 tests): - 3x3 board with win/draw detection - Bug variants: wrong diagonal indices, turn not alternating Game of Life (~230 lines, 20 tests): - Cellular automaton with birth/death rules - Bug variants: missing diagonal neighbors (easy), wrong survival threshold (medium), sequential instead of simultaneous update (hard) Calculator (~270 lines, 28 tests): - Expression parser with operator precedence - Tokenizer, recursive descent parser, evaluator - Bug variants: flat precedence, right-associativity Documentation updates: - hazel-primer.md: Added note about comment syntax - experience-log.md: Documented eval reserved name and comment gotchas - Each program folder has detailed README with bug descriptions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## probe-III #2056 +/- ##
=============================================
+ Coverage 49.95% 50.66% +0.71%
=============================================
Files 230 219 -11
Lines 25600 25105 -495
=============================================
- Hits 12788 12719 -69
+ Misses 12812 12386 -426
🚀 New features to boost your workflow:
|
CLI changes: - Add --auto/-a flag to ./hazel probe command - When enabled, uses AutoProbe.ids_to_autoprobe to automatically place probes on expressions (one per line heuristic) - Works with existing --many flag for multiple samples Study-write tasks for probes user study: - basepoint: tiny task, parameter order ambiguity - clamp: tiny task, condition boundary errors - running-sum: small task, fold accumulator errors - Each has sketch, solution, and storyboard files - Tests formatted with line breaks for auto-probe visibility Also includes: - study-write-plan.md: research questions, task categories, design notes - cli-autoprobe-proposal.md: implementation design document - session-log.md: example incremental CLI session Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Replace verbose ^^probe(...) with cleaner ⟦...⟧ brackets in CLI output - Fix probe values appearing on first line of multi-line expressions (now correctly placed at end of expression using m.last.row) - Add Token.probe_start/probe_end constants for Unicode brackets - Add refractor_seg_to_seg_text for customizable probe rendering Co-Authored-By: Claude Opus 4.5 <[email protected]>
Changed ~indent="" to skip Printer's computed indentation, which was causing output to have different (usually more) indentation than the source file. The computed indentation is designed for Hazel's structural editor, but CLI output should preserve the original whitespace from the parsed segment. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Botanical/celestial themed tutorial introducing probes: - Seeing values with basic probes - Environment hover for variable values - Branches and the ∅ (not evaluated) icon - Functions and multiple samples - Closure cursor and sample alignment - Single/many mode, arrow key navigation Uses ⟦⟧ bracket notation to represent probed expressions in text. Sets up for Part 2: larger Greenhouse Planner program with debugging. Co-Authored-By: Claude Opus 4.5 <[email protected]>
New study-write tasks with sketch/solution pairs: - emojipaint-extend: Extend emoji paint with new brush feature - last-element: Find the last element of a list - mentions: Extract @mentions from text - safe-head: Safe version of list head with Option type Each task includes storyboard documentation for guided exploration. Also adds task-ideas.md and CLI syntax exploration notes. Co-Authored-By: Claude Opus 4.5 <[email protected]>
New commands: - ./hazel gen-slides: Generate ML slide files from hazel-programs/examples/ - ./hazel gen-slides-clean: Remove generated files and restore empty stub Features: - Recursively finds all .hz files in the examples directory - Parses each file and serializes to PersistentSegment format - Generates individual ML files for each program - Creates AllExamples.re aggregation module - Strips leading indentation before parsing (configurable) - Hierarchical slide titles based on directory structure Configuration in src/CLI/GenSlides.re (input_dir, output_dir, root_title, etc.) Integration: - Added examples library to web dependencies - Added Examples.AllExamples.all to Init.re documentation list - Stub AllExamples.re allows build to succeed when slides not generated Co-Authored-By: Claude Opus 4.5 <[email protected]>
Resolve merge conflicts from refactors.manuals changing from Id.Map.t to RefractorList.t (association list). Updated call sites to use list operations instead of Id.Map operations: - Printer.re: Use [] instead of Id.Map.empty for default refractors - Triggers.re: Update type annotations and use List.assoc_opt, ListUtil.remove_assoc, List.is_empty - Cli.re: Build refractor list instead of Map, fold into list - ProbeSidebar.re: Add missing projector_list arg to mk_view, convert manuals to Map for RefractorView.mk_data - Test_ExpToSegment.re: Use [] for empty refractors Co-Authored-By: Claude Opus 4.5 <[email protected]>
Convert recursive do_until and do_until_piece functions in Zipper.re to iterative implementations using while loops. The previous recursive versions would overflow the JavaScript call stack when traversing documents with thousands of tokens. Also includes related refactoring: - Move Sample.Capture type to its own submodule in Sample.re to avoid type inference issues with overlapping field names - Add clear_transient() to EvaluatorState to prevent serializing large app_args data (~100MB+) over postMessage - Only store app_args for probe target IDs to reduce memory usage Co-Authored-By: Claude Opus 4.5 <[email protected]>
When a function argument is syntactically just a variable (e.g., g(x)), filter that variable from the environment display since its value is already visible in the call display (e.g., g(5)). - Add get_arg_var_names to extract variable names from direct Var args - Handles tuples: f(x, y+1) filters x but keeps y - Handles parenthesized expressions - Update sample_environment to accept filter_vars parameter Co-Authored-By: Claude Opus 4.5 <[email protected]>
The autosave was slow because ScratchMode.persist was calling PersistentZipper.unpersist on every original documentation slide on every save, just to compare if they had changed. This adds a lazily-initialized cache in Init.re that stores the original segments, so the comparison is now a fast map lookup instead of re-parsing S-expressions. Co-Authored-By: Claude Opus 4.5 <[email protected]>
The stack_frame type was a tuple (Id.t, option(string)) where the
optional string (function name) is purely informational. Many comparison
sites used structural equality (==) on stack frames, which broke after
step-into because the cursor constructs frames with name=None while
evaluation produces frames with name=Some("f"). This caused the sample
selection logic to fail even though filter_by_pin (which used
ids_of_stack) worked correctly.
Changes:
- Convert stack_frame from tuple to record {id, name}
- Add equal_stack_frame (id-only) and equal_call_stack helpers
- Fix all comparison sites to use id-only equality
- Add ~eq parameter to ListUtil suffix/comparison functions
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Test_SampleSelection.re (28 unit tests): Tests pure Selection/Cursor logic with hand-crafted samples. Covers equal_stack_frame, Cursor.relation, filter_by_pin, select in Single/Many modes, is_same_call, closest_to_cursor, and get_empty_status. Includes regression tests for None-vs-Some name mismatch that caused the step-into bug. Test_Evaluator_ProbeSelection.re (11 integration tests): Evaluates real programs, then pipes samples through Selection with simulated cursor/pin states. Tests step-into scenarios, pin filtering between calls, cursor relation classification, and Single vs Many mode behavior with real data. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add fn_def_id to stack_frame for jump-to-definition from built-in internal calls. Add fallback navigation for built-in function entries: when clicking a name or separator that points to non-navigable built-in code, walk up the call stack to the nearest user-visible call site. Key fix: HazelFn built-ins use a "+" suffix on internal names (e.g. "fold_left+"), so strip it before checking Builtins.env_init to correctly identify built-in entries and skip non-navigable definition targets. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Simplify click handlers to uniformly set cursor index to the clicked entry's depth, regardless of whether the jump target is a direct definition or a fallback. The jump target and cursor index are independent concerns: the cursor reflects what depth you're inspecting, not where the syntax jump lands. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Change name clicks from jump-to-definition to jump-to-call-site for more intuitive backtracking. Separators become decorative (no click). Add body icon at end of bar to jump to the innermost function definition, preserving the ability to navigate forward after backtracking. Co-Authored-By: Claude Opus 4.6 <[email protected]>
When stepping deep into a call stack, probes on application expressions that are part of the pinned call chain now remain visible instead of being filtered out. Only probes whose ap_id matches a frame in the pinned stack are kept, so sibling branches and non-application probes at shallower depths are still filtered. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.