Skip to content

feat(codegraff): wire all REPL tiers into TUI dispatcher (Tiers 2-7 of #22)#24

Closed
justrach wants to merge 4 commits into
mainfrom
feat/codegraff-all-tiers
Closed

feat(codegraff): wire all REPL tiers into TUI dispatcher (Tiers 2-7 of #22)#24
justrach wants to merge 4 commits into
mainfrom
feat/codegraff-all-tiers

Conversation

@justrach

@justrach justrach commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary

Closes Tiers 2-7 of #22. Stacks on PR #23 (Tier 1).

Adds 32 new slash commands to the codegraff TUI dispatcher with full PALETTE_COMMANDS coverage. PR is one big commit because the changes are mechanical — same handler pattern repeated, all touching the same main.rs.

Wired commands (functional)

Tier 2 — agent switching

  • /act, /plan, /sage — direct switches via set_active_agent
  • /agent (no arg lists, /agent <id> switches)

Tier 3 — conversation management

  • /conversation / /conversations — list via get_conversations
  • /rename <title>, /conversation-rename <title>rename_conversation
  • /compactcompact_conversation
  • /dump (--html for HTML wrapper) — serialize to ~/forge/dumps/<id>-<ts>.<ext>

Tier 4 — config

  • /config — print effective session config
  • /config-edit — open ~/forge/.forge.toml in $EDITOR/$FORGE_EDITOR
  • /fast — toggle Priority Processing
  • /reasoning-effort <level>, /config-reasoning-effort <level> — set effort
  • /config-model <id>, /config-commit-model <id>, /config-suggest-model <id> — arg-form setters; provider resolved from current session config

Tier 5 — workspace + tools

  • /workspace-sync / /sync, /indexsync_workspace, consume progress stream
  • /workspace-status / /sync-statusget_workspace_status
  • /workspace-info / /sync-infoget_workspace_info
  • /workspace-init / /sync-initinit_workspace
  • /skill / /skillsget_skills
  • /toolsget_tools
  • /suggest <description>generate_command

Tier 6 — git

  • /commit-preview, /commitcommit(preview, ...)

Tier 7 — admin

  • /logoutremove_provider for the default provider
  • /update — runs install script via execute_shell_command_raw

Deferred with helpful status messages

  • /clone — no API method available; user routed to graff REPL :clone.
  • /copy — Context message-walker not threaded into the TUI; deferred with hint to use terminal selection or graff REPL :copy.
  • /config-reload — no clean reload API; user told to restart codegraff.

Tests

  • cargo test -p codegraff --bin codegraff palette — 8 tests pass.
  • palette_includes_locally_handled_commands requires all 43 commands to be in PALETTE_COMMANDS (catches drift between dispatcher and palette).

Test plan

  • / → palette shows all 43 commands, fuzzy filter works
  • /act, /plan, /sage → status entry confirms agent switch
  • /agent (no arg) → lists agents; /agent forge switches
  • /conversation → lists workspace conversations
  • /rename hello → renames; verify /conversation shows new title
  • /dump → JSON file written to ~/forge/dumps/; /dump --html wraps in HTML
  • /compact → status entry shows compaction result
  • /config → effective config printed
  • /fast → toggles, status confirms
  • /reasoning-effort high → status confirms
  • /skill, /tools, /suggest list files → outputs printed
  • /commit-preview → message preview without committing
  • /clone, /copy, /config-reload → helpful "deferred, see Wire remaining REPL commands into codegraff TUI handle_enter #22" status

Out of scope

🤖 Generated with Claude Code

justrach and others added 4 commits May 5, 2026 03:18
Adds a fuzzy slash command palette to the codegraff TUI. Typing `/`
when the composer is empty opens a centered overlay listing all
slash commands ported from graff's REPL AppCommand enum, plus
codegraff-specific commands (/workflow, /image, /logs, etc.).

Implementation notes:
- New Overlay::CommandPalette variant with CommandPaletteState
  (query + selected_index) lives next to the existing overlay types
  in main.rs to avoid risky refactors.
- Static PALETTE_COMMANDS table holds (name, description). The list
  mirrors crates/forge_main/src/model.rs, excluding REPL-only
  entries (:exit, :edit, :retry).
- Fuzzy ranking uses the workspace `nucleo` dep (already declared in
  Cargo.toml). Items with score 0 are filtered out; ties preserve
  catalogue order.
- `dispatch_command_palette` writes "/<name>" into self.composer and
  reuses the existing handle_enter dispatch path, so commands like
  /workflow keep their parser unchanged.
- Keybindings: Up/Down navigate, Tab autocompletes, Enter dispatches,
  Esc closes, Backspace deletes (closes when query empty), any other
  char appends to the query.
- Render path calls Clear over the overlay rect; full-frame Clear at
  the top of render() prevents close artifacts. overlay_area is
  recomputed each frame, so resize re-clamps automatically.

Tests cover empty-query catalogue, fuzzy match, zero-score filter,
catalogue uniqueness, REPL-only exclusion, and rendered line content.
All 118 codegraff bin tests pass; clippy and release build are clean.

Closes #17

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

Pre-merge review caught that ~30 entries in PALETTE_COMMANDS exposed
commands the codegraff TUI dispatcher does not yet handle locally
(`/new`, `/info`, `/agent`, `/commit`, `/dump`, `/skill`, `/tools`,
`/copy`, `/clone`, `/conversation*`, `/workspace-*`, `/index`, `/update`,
`/compact`, `/sage`, `/help`, `/plan`, `/act`, `/rename`, `/fast`,
`/config-*`, `/suggest`, etc.). Selecting any of those from the palette
would silently send the literal slash text to the LLM as a chat message,
which is strictly worse UX than not exposing them.

Restrict the palette to the 8 commands `handle_enter` does route:
`/connect`, `/image`, `/login`, `/logs`, `/model`, `/models`, `/usage`,
`/workflow`. Wiring the rest into the TUI dispatcher is tracked in a
follow-up issue under the parity tracker.

Also tighten `palette_command_names_are_unique_and_lowercase` to
actually assert lowercase (it didn't before — name was misleading) and
add a sanity test confirming every locally-handled command is in the
palette so the dispatcher stays in sync.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds local handlers for the three highest-traffic Tier 1 commands from
the parity tracker (#22), plus the corresponding palette entries:

- `/new` — calls `Conversation::generate()` + `upsert_conversation`,
  then resets transcript, image attachments, pending pastes, usage,
  and any in-flight workflow. Active model is preserved.
- `/info` — pushes status entries for active agent, model label,
  conversation id, and log path. TUI equivalent of the REPL `:info`
  Info widget.
- `/help` — opens the command palette (the discovery surface). Cheap
  alias so `/help` does the natural thing in a TUI.

The `palette_includes_locally_handled_commands` test is updated to
require these three names.

This keeps PALETTE_COMMANDS in lockstep with handle_enter — no ghost
commands. Remaining tiers (agent switching, conversation management,
config, workspace, git) tracked in #22.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Closes Tiers 2-7 of #22.

Adds 32 new slash commands to the codegraff TUI dispatcher with full
PALETTE_COMMANDS coverage and matching test entries. Rough split:

- Tier 2 (agent switching): /act, /plan, /sage, /agent. /agent without
  args lists available agents; with arg switches.
- Tier 3 (conversation): /conversation(s), /rename, /conversation-rename,
  /dump (json or --html), /compact. /clone and /copy are deferred with
  helpful status messages.
- Tier 4 (config): /config, /config-edit (opens $EDITOR on
  ~/forge/.forge.toml), /fast (toggle), /reasoning-effort and
  /config-reasoning-effort (arg form), /config-model,
  /config-commit-model, /config-suggest-model (provider resolved from
  current session). /config-reload deferred.
- Tier 5 (workspace + tools): /workspace-sync, /sync, /index,
  /workspace-status, /workspace-info, /workspace-init, /skill, /tools,
  /suggest.
- Tier 6 (git): /commit, /commit-preview.
- Tier 7 (admin): /logout (removes default provider creds), /update
  (runs the install script).

Adds chrono, dirs, serde_json to the codegraff-tui Cargo.toml; all are
already in workspace deps. New code shares the same pattern as the
existing /usage / /new / /info handlers.

Note: most workspace + tools handlers print debug-formatted results
(using {:?}) for now; richer rendering can land as follow-ups under
the parity tracker.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@justrach justrach changed the base branch from feat/codegraff-tier1-commands to main May 5, 2026 03:52
@justrach

justrach commented May 5, 2026

Copy link
Copy Markdown
Owner Author

Superseded by a rebased branch — see new PR. Stack reshuffle after squash-merging palette base.

@justrach justrach closed this May 5, 2026
@github-actions github-actions Bot added type: feature Brand new functionality, features, pages, workflows, endpoints, etc. type: fix Iterations on existing features or infrastructure. labels May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Brand new functionality, features, pages, workflows, endpoints, etc. type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant