Commit Graph

297 Commits

Author SHA1 Message Date
07c8f4a40a docs: update repo-map and design-principles for pest parser
- Document PEG grammar as single source of truth for .improv format
- Update file format section with v2025-04-09 syntax: version line,
  Initial View, pipe quoting, Views→Formulas→Categories→Data order
- Add pipe quoting convention and grammar-driven testing principles
- Update file inventory (persistence: 124+2291 lines, 83 tests)
- Add pest/pest_meta to dependency table
- Update persistence testing guidance for grammar-walking generator

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Executed-By: spot
2026-04-11 00:08:01 -07:00
70e7cfbef7 chore: update gitignore and claude instructions 2026-04-11 00:08:01 -07:00
d34e8eb313 feat: replace ad-hoc .improv parser with pest grammar
- Add improv.pest PEG grammar as the single source of truth for the
  .improv file format (v2025-04-09)
- Replace hand-written line scanner with pest-derived parser that walks
  the grammar's parse tree
- Add grammar-walking test generator that reads improv.pest at test time
  via pest_meta and produces random valid files from the AST
- Fix 6 parser bugs: newlines in text, commas in names, brackets in
  names, float precision, view name ambiguity, group brackets
- New format: version line, Initial View header, pipe quoting (|...|),
  Views→Formulas→Categories→Data section order, comma-separated items
- Bare names restricted to [A-Za-z_][A-Za-z0-9_-]*, everything else
  pipe-quoted with \| \\ \n escapes
- Remove all unwrap() calls from production code, propagate errors
  with Result throughout parse_md
- Extract shared escape_pipe/unescape_pipe/pipe_quote helpers, deduplicate
  hidden/collapsed formatting, add w!() macro for infallible writeln

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Executed-By: spot
2026-04-11 00:08:00 -07:00
4d7d91257d refactor: colocate cmd tests with their modules
Move tests from the monolithic tests.rs into #[cfg(test)] mod tests
blocks in each command module. Shared test helpers live in
mod.rs::test_helpers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Executed-By: fido
2026-04-11 00:08:00 -07:00
001744f5cf docs: update design-principles for _Measure and fixed-point eval
Add VirtualMeasure to CategoryKind description, document _Measure as
third always-present virtual category, add section on fixed-point
formula evaluation strategy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:08:00 -07:00
326e245c48 docs: update repo-map for _Measure, CellValue::Error, fixed-point eval
Reflect _Measure virtual category, VirtualMeasure kind, CellValue::Error
variant, recompute_formulas fixed-point cache, and add_formula auto-adding
target items.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:08:00 -07:00
afbcf7b3ff chore: update demo data for new format 2026-04-11 00:08:00 -07:00
e6c93a24d9 chore: some dep updates 2026-04-11 00:07:59 -07:00
23a876d556 feat: rename Measure to _Measure (virtual), add fixed-point formula eval
_Measure is now a virtual category (CategoryKind::VirtualMeasure),
created automatically in Model::new() alongside _Index and _Dim.
Formula targets are added as items automatically by add_formula.

Formula evaluation uses a fixed-point cache: recompute_formulas()
iterates evaluation of all formula cells until values stabilize,
resolving refs through the cache for formula values and raw data
aggregation for non-formula values. This fixes formulas that
reference other measures when hidden dimensions are present.

evaluate_aggregated now checks the formula cache instead of
recursively evaluating formulas, breaking the dependency between
formula evaluation and aggregation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:59 -07:00
fd69126cdc refactor: split cmd.rs 2026-04-11 00:07:59 -07:00
767d524d4b unwind LFS for now 2026-04-11 00:07:59 -07:00
24c59fbf40 fix: Model::add_formula auto-adds target item; fix formula panel display
Model::add_formula now ensures the formula target exists as an item in
the target category (same fix as AddFormula effect, but at the model
level — covers file loading and headless paths).

Formula panel now shows raw formula text instead of debug-formatted
string with redundant target name and quotes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:59 -07:00
4686f47026 fix: scroll tile bar to keep selected tile visible
When there are more tiles than fit in the available width, the tile
bar now auto-scrolls to ensure the selected tile is always visible.
Overflow indicators (◀ ▶) show when tiles exist beyond the visible
area. Scroll offset is computed fresh each frame from tile_cat_idx.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:58 -07:00
737d14a5c0 fix: add depth limit to formula evaluation, propagate errors
Circular or self-referencing formulas now return CellValue::Error
instead of stack overflowing. eval_expr uses Result<f64, String>
internally so errors (circular refs, div/0, missing refs) propagate
immediately through the expression tree via ?. The depth limit (16)
is checked per evaluate_depth call — normal 1-2 level chains are
unaffected.

Also adds CellValue::Error variant for displaying ERR:reason in the
grid, and handles it in format, persistence, and search.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:58 -07:00
32d215f3d6 fix: AddFormula now adds target item to category
When adding a formula interactively, the target (e.g. "Margin") was
registered as a formula but never added as an item to the target
category. The grid layout never created cells for it, making the
formula invisible. Now AddFormula::apply calls add_item before
registering the formula.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:58 -07:00
a61d7aa229 feat(demo): add asciinema casts for pivot, drill, formulas, import
Four recorded casts at 100x30 with 2s idle cap:
- pivot.cast: axis reassignment with tile mode
- drill.cast: drill-down into aggregated cells
- formulas.cast: formula panel and adding formulas
- import.cast: CSV import wizard walkthrough

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:58 -07:00
e00f2e032e feat(demo): add VHS demo tape and generated GIF
Create docs/demo.tape scripting a ~15s pivot axis reassignment demo.
Hide shell startup and quit so the GIF opens directly on the TUI.
Set up git-lfs for docs/*.gif. Merge LFS hooks with existing beads hooks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:57 -07:00
280339ea10 feat(nix): add asciinema, vhs, and cargo-dist to dev shell
Add demo recording tools (asciinema, vhs) and release tooling
(cargo-dist) to nativeBuildInputs. Include a cargo-dist wrapper so
`cargo dist` works as a subcommand. Add scripts/record-demo.sh for
consistent asciinema cast recording at 100x30.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:57 -07:00
6239ac83ad chore: fmt + clippy 2026-04-11 00:07:57 -07:00
08df85664e feat: add examples/demo.csv and examples/demo.improv
40-row CSV with obviously-fake sales data (fictional companies like
Acme Corp, Wonka Industries, Cyberdyne Systems). demo.improv generated
via headless import with Profit formula and a default view showing
Region+Product on rows, Date_Month+Measure on columns. Added the
import command to the README quick-start section.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:57 -07:00
d3d1df0be2 docs: expand README with concrete details
Add dedicated sections for the data model (formula examples), views and
axes (tile mode, records mode, drill-down), the .improv file format
(annotated example), import wizard and headless scripting, and the
command/effect architecture. Link docs/design-notes.md from the "Why"
section. Update build instructions to use `nix build .`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:57 -07:00
4751b800fd chore: remove stale SPEC.md, salvage vision into docs/design-notes.md
Audited SPEC.md against code — mostly accurate but redundant with
repo-map.md and design-principles.md. Minor drift in storage internals,
wizard step count, and mode representation. Salvaged product vision and
non-goals into docs/design-notes.md with staleness disclaimer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:57 -07:00
ecd001e589 chore: add Apache-2.0 LICENSE file
Pulled from apache.org/licenses/LICENSE-2.0.txt.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:57 -07:00
3338601a6c chore: fix stale MIT reference in repo-map to Apache-2.0
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:57 -07:00
861b142dec chore: change license to Apache-2.0
Update both README and Cargo.toml.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:57 -07:00
769a5eb443 docs: write README for Show HN launch
All 10 sections per the launch plan: title, pitch, demo GIF placeholder,
Lotus Improv context, quick start, key bindings, installation (Nix/crates.io/
prebuilt), codebase overview, expectations disclaimer, license. Under 100
lines, no badges or TOC.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:56 -07:00
b610f7ad66 chore: update CLAUDe.md 2026-04-11 00:07:56 -07:00
ad9ea30fc2 test(csv): add RFC 4180 edge case tests for CSV quote handling
Audit confirms the csv crate correctly handles all RFC 4180 cases:
- Embedded commas in quoted fields
- Escaped quotes ("") within quoted fields
- Embedded newlines in quoted fields
- Combined commas + escaped quotes

No bugs found — added 4 regression tests to document compliance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:07:56 -07:00
11bcc5d04d Merge branch 'main' of git.fiddlerwoaroof.com:u/edwlan/improvise 2026-04-11 00:07:48 -07:00
fb8b6ca053 feat(formula): support pipe-quoted identifiers |...|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:06:51 -07:00
ab7e00a217 feat(formula): support pipe-quoted identifiers |...|
Add CL/SQL-style symbol quoting using pipe delimiters for formula
identifiers. This allows category and item names that collide with
keywords (WHERE, SUM, IF, etc.) or contain special characters
(parens, operators, spaces) to be used unambiguously in formulas:

  |WHERE| + |Revenue (USD)|
  SUM(|Net Revenue| WHERE |Region Name| = |East Coast|)

Pipes produce Token::Ident (same as bare identifiers), so they work
everywhere: expressions, aggregates, WHERE clauses. Double-quoted
strings remain Token::Str for backward compatibility.

Also updates split_where and parse_where to skip/strip pipe delimiters.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:06:51 -07:00
35ed6a13bf fix: add missing Cargo.toml package metadata
Add repository, homepage, readme, keywords, and categories fields.
Update description to match project vision. Use GitHub URLs for
public discoverability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:06:51 -07:00
637178f3f6 fix: add missing Cargo.toml package metadata
Add repository, homepage, readme, keywords, and categories fields.
Update description to match project vision.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:06:51 -07:00
09df7bf181 docs: update design principles and repo map after test audit
- Add virtual category boundary rule: use regular_category_names() for
  user-facing logic, never expose _Index/_Dim
- Document formula tokenizer keyword-aware identifier breaking
- Update repo-map test counts (356 → 510) and add regular_category_names

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:06:51 -07:00
96d783a1c5 chore: update gitignore 2026-04-11 00:06:51 -07:00
e67f4d5a92 fix(formula): break tokenizer identifiers when current word is a keyword
The tokenizer already broke multi-word identifiers when the NEXT word
was a keyword, but not when the identifier collected SO FAR was a
keyword. This meant "WHERE Region" was merged into one token when
tokenizing "SUM(Revenue WHERE Region = East)".

Now the tokenizer also checks if the identifier built up to the current
space IS a keyword (WHERE, SUM, AVG, MIN, MAX, COUNT, IF), which
correctly produces separate tokens for "Revenue", "WHERE", "Region".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 00:06:51 -07:00
4c8ba6400b refactor: use regular_category_names in command and import wizard
Updates `CommitFormula` and `ImportPipeline` to use
`regular_category_names` instead of `category_names` . This ensures that
these components do not target or default to virtual categories (_Index,
_Dim) when no regular categories are present.

Includes updated tests for `CommitFormula` to verify it correctly handles
cases with no regular categories.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
db170a10b8 feat(model): add regular_category_names to Model
Updates `Model` to include `regular_category_names` , which returns
category names excluding virtual categories (_Index, _Dim). This allows
other parts of the application to distinguish between user-defined
categories and system-internal ones.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
d14ec443c2 feat(formula): improve tokenizer to correctly handle keywords and delimiters
The tokenizer was greedily consuming spaces and potentially merging
identifiers with subsequent keywords. This change improves the tokenizer
by:
- Peeking ahead past spaces to find the next word/token.
- Breaking the identifier if the next word is a known keyword (WHERE, SUM,
  AVG, MIN, MAX, COUNT, IF).
- Adding support for more delimiter characters (<, >, =, !, ").

This fixes a regression where "Revenue WHERE" was treated as a single
identifier instead of an identifier followed by a WHERE clause.

Includes a new regression test for inline WHERE filters in aggregate
functions.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
a83a4f604f chore: improve test coverage of mod.rs 2026-04-11 00:06:50 -07:00
c8607b78ba test(ui): add unit tests for effects
Add unit tests for UI effects, covering:
- Model mutations
- View navigation
- App state changes
- Drill-down functionality

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
687cf80698 test(import): add unit tests for import wizard and pipeline
Add unit tests for ImportWizard and ImportPipeline, covering:
- Wizard step transitions
- Proposal and formula editing
- Date configuration
- Edge cases for building the data model

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
96a4cda368 test(formula): add unit tests for formula parser
Add a comprehensive suite of unit tests for the formula parser, covering:
- Aggregate functions
- WHERE clauses
- Comparison operators
- Arithmetic operations
- Various error handling scenarios

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
5f71321980 test(command): add unit tests for various commands
Add unit tests for various commands including PasteCell, TransposeAxes,
ViewNavigate, and MovePanelCursor to ensure correct command execution and
state changes.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
a3d8adfb45 refactor(command): improve axis operation feedback
Improve feedback for axis operations:

- `CycleAxisAtCursor` : Now provides a status message if no category is at
  the cursor.
- `TileAxisOp` :
    - Now provides a status message showing the new axis (e.g., "Category →
      Row").
    - No longer automatically switches to `AppMode::Normal` , allowing for
      multiple consecutive adjustments.
    - Provides a status message if no category is at the cursor.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
da076eadc8 test(model,ui): add tests for precision and cat tree
Add unit tests for model precision and category tree rendering:

- `src/model/types.rs` : Added `formula_chain_preserves_full_precision` to
  ensure formulas use full `f64` precision for calculations, even when
  display is rounded.
- `src/ui/cat_tree.rs` : Added comprehensive tests for `build_cat_tree` ,
  covering empty models (virtual categories), expanded/collapsed states,
  and item rendering.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
433a20928a refactor(format): improve number formatting and rounding
Improve number formatting and add comprehensive tests:

- Implemented `round_half_away` to provide more intuitive rounding (e.g.,
  2.5 -> 3, -2.5 -> -3).
- Updated `format_f64` to use this rounding logic.
- Added extensive unit tests for `parse_number_format` and `format_f64` ,
  covering various edge cases and rounding behaviors.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
7dd9d906c1 refactor(ui): improve rendering, feedback, and help system
Improve UI rendering and feedback:

- `src/draw.rs` :
    - Automatically enter Help mode if the model is empty.
    - Render the `HelpWidget` with the current help page.
    - Render the `WhichKeyWidget` when a transient keymap is active.
- `src/ui/tile_bar.rs` : Use more descriptive labels for axes (e.g., "Row",
  "Col", "Pag").
- `src/ui/view_panel.rs` :
    - Include an axis summary (e.g., "R:Region C:Product") next to view
      names.
    - Refactor `ViewContent` to hold a reference to the `Model` .
- `src/ui/effect.rs` : Add error feedback to `AddItem` , `AddItemInGroup` ,
  and `AddFormula` when operations fail.
- `src/ui/help.rs` : Refactor `HelpWidget` into a multi-page system.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
2b1f42d8bf refactor(command): update keymaps for command mode and help navigation
Update keymaps to allow entering command mode via ':' in various panels and
add help page navigation.

- Added ':' command binding to Help, FormulaPanel, CategoryPanel,
  ViewPanel, and TileSelect modes.
- Added navigation bindings (Right/Left, l/h, n/p, Tab/BackTab) to the Help
  keymap.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:50 -07:00
d49bcf0060 feat(ui): implement which-key popup for command completions
Implement `WhichKey` popup to show available command completions.

- Added `format_key_label` to convert `KeyCode` to human-readable strings.
- Added `binding_hints` to `Keymap` to extract available commands for a
  given prefix.
- Added `src/ui/which_key.rs` for the widget implementation.
- Updated `src/ui/mod.rs` to export the new module.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
2026-04-11 00:06:49 -07:00