Skip to content

feat(fish): complete Fish shell adapter with full feature parity#58

Open
lacymorrow wants to merge 1 commit into
mainfrom
feat/fish-shell-support
Open

feat(fish): complete Fish shell adapter with full feature parity#58
lacymorrow wants to merge 1 commit into
mainfrom
feat/fish-shell-support

Conversation

@lacymorrow

Copy link
Copy Markdown
Owner

Summary

Closes #36. Completes the Fish shell adapter (Fish 3.1+) with full feature parity against the Bash adapter:

  • Detection: Full _lacy_classify_input with all ~150 agent words, shell reserved words, @/! bypass prefixes, env-var assignment handling, and multi-word heuristics
  • Execution routing: Enter key intercepts, session commands (/new, /reset, /clear, /resume), emergency/agent bypass prefixes
  • User commands: mode, tool, ask, quit/stop — all available as Fish functions
  • Tool support: All 10 AI tools (lash, claude, opencode, gemini, codex, hermes, copilot, goose, amp, aider) + custom
  • Tab completions: For lacy, mode, and tool commands
  • Keybindings: Enter override via bind \r, Ctrl+Space mode toggle, coexists with user's fish_user_key_bindings
  • Prompt: Mode badge in fish_right_prompt (wraps existing right prompt if present)
  • Cleanup/quit: Full teardown restoring original bindings and prompt

Also updates bin/lacy completions fish, README, CLAUDE.md, and docs to reflect Fish support.

Test plan

  • Install Fish 3.1+ and source lacy.plugin.fish
  • Verify mode toggle (Ctrl+Space cycles auto → shell → agent → auto)
  • Verify detection: ls -la → shell, what files are here → agent
  • Verify /new and /resume session commands
  • Verify !cmd bypass sends directly to shell
  • Verify @query bypass sends directly to agent
  • Verify mode shell, mode agent, mode auto commands
  • Verify tool shows installed tools, tool set claude switches
  • Verify ask "question" routes to agent
  • Verify quit cleans up bindings and restores prompt
  • Verify lacy completions fish outputs valid completions script

Expands the existing Fish shell skeleton into a fully-featured adapter
matching the Bash adapter's capabilities: session commands (/new, /resume),
user-facing commands (mode, tool, ask, quit), agent/shell bypass prefixes
(@ and !), tab completions, all 10 supported AI tools, and cleanup/quit.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the Fish shell (3.1+) by implementing a native adapter for natural language detection, execution routing, and keybindings. The update includes new Fish-specific library files, documentation updates, and expanded CLI completions. Feedback identifies critical bugs in the cleanup routine, specifically that Enter keybindings and original user functions are not restored, which could break the shell. Other improvements suggested include refining the input classification heuristic to handle multiple spaces and ensuring the "ask" command supports multi-word queries.

Comment thread lib/fish/execute.fish
Comment on lines +282 to +283
bind --erase \n 2>/dev/null
bind --erase \r 2>/dev/null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Erasing the \n and \r bindings without restoring them will leave the shell unusable (the Enter key will stop working) until the shell is restarted. Instead of erasing, you should restore the default execute binding.

    bind \n execute 2>/dev/null
    bind \r execute 2>/dev/null

Comment thread lib/fish/execute.fish
Comment on lines +287 to +292
# Remove user-facing command functions
functions --erase mode 2>/dev/null
functions --erase tool 2>/dev/null
functions --erase ask 2>/dev/null
functions --erase quit 2>/dev/null
functions --erase stop 2>/dev/null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The fish_user_key_bindings function was wrapped in lib/fish/keybindings.fish but is not restored during cleanup. This leaves a broken function that attempts to call the erased _lacy_setup_bindings function. You should restore the original function if it was backed up.

    # Restore original keybindings function if we wrapped it
    if functions -q _lacy_original_key_bindings
        functions -c _lacy_original_key_bindings fish_user_key_bindings
        functions --erase _lacy_original_key_bindings
    end

    # Remove user-facing command functions
    functions --erase mode tool ask quit stop 2>/dev/null

Comment thread lib/fish/detection.fish

# Auto mode — apply heuristics
# Split into words
set -l words (string split ' ' -- "$input")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using string split ' ' will include empty strings in the result if the input contains multiple consecutive spaces (e.g., ls -la). This can cause the word_count and the bare word heuristic (lines 105-112) to behave incorrectly, potentially routing valid shell commands to the agent. Use the -n (or --no-empty) flag to skip empty results.

    set -l words (string split -n ' ' -- "$input")

Comment thread lib/fish/execute.fish
end

function ask --description "Lacy: send a query directly to the AI agent"
_lacy_query_agent "$argv"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ask function currently only sends the first word of the query to the AI agent because _lacy_query_agent only processes $argv[1]. To support multi-word queries without requiring quotes, join the arguments into a single string.

    _lacy_query_agent (string join ' ' -- $argv)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Fish shell support

1 participant