feat: Wire ForgivingParser into REPL command dispatch #4

Open
opened 2026-04-22 09:41:37 +02:00 by product-owner · 0 comments

Problem Statement

The ForgivingParser module exists with typo tolerance and alias expansion, but ReplCommand::from_str does not use it. Commands like serach (typo) or /q (alias) fail instead of being auto-corrected.

Current State

  • ForgivingParser implemented: crates/terraphim_agent/src/forgiving/parser.rs
  • Default aliases defined: q->search, h->help, etc. in aliases.rs
  • ReplCommand::from_str uses direct string matching in commands.rs
  • No integration between parser and REPL dispatch

Acceptance Criteria

  • ReplCommand::from_str uses ForgivingParser for command matching
  • Typo correction works: serach auto-corrects to search with notification
  • Alias expansion works: /q query expands to /search query
  • Case-insensitive command matching works
  • Auto-correction notifications display in interactive mode
  • Robot mode includes meta.auto_corrected flag in JSON response
  • cargo test -p terraphim_agent passes
  • cargo clippy -- -D warnings passes

Proposed Approach

  1. Modify ReplCommand::from_str in crates/terraphim_agent/src/repl/commands.rs to use ForgivingParser
  2. Handle ParseResult variants (Exact, AliasExpanded, AutoCorrected, Suggestions, Unknown)
  3. Add auto-correction notification in ReplHandler::execute_command
  4. Add auto_corrected flag to robot mode JSON responses

Dependencies

None

Verification

cargo test -p terraphim_agent --lib forgiving::parser::tests
cargo test -p terraphim_agent --test repl_integration_tests
cargo build -p terraphim_agent --features repl
cargo clippy -p terraphim_agent -- -D warnings

Scope

Modifies commands.rs and handler.rs. ~100 lines changed.

Upstream: This issue tracks a feature for terraphim/terraphim-ai

## Problem Statement The `ForgivingParser` module exists with typo tolerance and alias expansion, but `ReplCommand::from_str` does not use it. Commands like `serach` (typo) or `/q` (alias) fail instead of being auto-corrected. ## Current State - `ForgivingParser` implemented: `crates/terraphim_agent/src/forgiving/parser.rs` - Default aliases defined: `q->search`, `h->help`, etc. in `aliases.rs` - `ReplCommand::from_str` uses direct string matching in `commands.rs` - No integration between parser and REPL dispatch ## Acceptance Criteria - [ ] `ReplCommand::from_str` uses `ForgivingParser` for command matching - [ ] Typo correction works: `serach` auto-corrects to `search` with notification - [ ] Alias expansion works: `/q query` expands to `/search query` - [ ] Case-insensitive command matching works - [ ] Auto-correction notifications display in interactive mode - [ ] Robot mode includes `meta.auto_corrected` flag in JSON response - [ ] cargo test -p terraphim_agent passes - [ ] cargo clippy -- -D warnings passes ## Proposed Approach 1. Modify `ReplCommand::from_str` in `crates/terraphim_agent/src/repl/commands.rs` to use `ForgivingParser` 2. Handle `ParseResult` variants (Exact, AliasExpanded, AutoCorrected, Suggestions, Unknown) 3. Add auto-correction notification in `ReplHandler::execute_command` 4. Add `auto_corrected` flag to robot mode JSON responses ## Dependencies None ## Verification ```bash cargo test -p terraphim_agent --lib forgiving::parser::tests cargo test -p terraphim_agent --test repl_integration_tests cargo build -p terraphim_agent --features repl cargo clippy -p terraphim_agent -- -D warnings ``` ## Scope Modifies `commands.rs` and `handler.rs`. ~100 lines changed. Upstream: This issue tracks a feature for terraphim/terraphim-ai
root added a new dependency 2026-04-24 03:05:03 +02:00
root added a new dependency 2026-04-25 06:02:59 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: terraphim/agent-tasks#4