Skip to content

feat(cli): add /md command to render markdown files#8305

Closed
mvanhorn wants to merge 2 commits intoaaif-goose:mainfrom
mvanhorn:feat/8249-md-slash-command
Closed

feat(cli): add /md command to render markdown files#8305
mvanhorn wants to merge 2 commits intoaaif-goose:mainfrom
mvanhorn:feat/8249-md-slash-command

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented Apr 4, 2026

Summary

Adds a /md <file> slash command to the interactive CLI session. Reads a markdown file and renders it in the terminal using the existing print_markdown function (bat-based syntax highlighting, table extraction, theme support).

Changes

  • crates/goose-cli/src/session/input.rs: Added /md <path> handler in handle_slash_command(). Reads the file with std::fs::read_to_string, renders via print_markdown_for_command, returns InputResult::Retry to re-show the prompt.
  • crates/goose-cli/src/session/output.rs: Added pub fn print_markdown_for_command(content: &str) wrapper that calls print_markdown with the current theme from get_theme().
  • crates/goose-cli/src/session/completion.rs: Added /md to the slash command completion list.

Error handling: prints "Error reading : " for missing/unreadable files. Shows "Usage: /md " for empty path.

Testing

Verified via cargo clippy and cargo fmt. The implementation reuses existing, tested infrastructure (print_markdown, get_theme, InputResult::Retry pattern).

Fixes #8249

This contribution was developed with AI assistance (Codex).

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70b57ebb13

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose-cli/src/session/input.rs Outdated
println!("{}", console::style("⚠️ Note: /summarize has been renamed to /compact and will be removed in a future release.").yellow());
Some(InputResult::Compact)
}
s if s.starts_with("/md ") => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match bare /md command before requiring an argument

The new slash-command branch only matches s.starts_with("/md "), so entering /md without a trailing space does not hit this handler and is treated as a normal chat message (InputResult::Message) instead of showing the intended usage/retry path. This causes an unintended model request whenever a user types /md directly (or removes the auto-inserted space), so the command parser should explicitly handle the exact /md token as invalid usage.

Useful? React with 👍 / 👎.

@michaelneale
Copy link
Copy Markdown
Collaborator

thanks @mvanhorn - do you want to sign the DCO so we can get this in? also - we are moving to ui/text for the TUI, may be worth considering there.

mvanhorn added 2 commits April 5, 2026 20:16
Adds a /md <file> slash command that reads a markdown file and
renders it in the terminal using the existing print_markdown
function with bat-based syntax highlighting and theme support.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Typing /md without a space was falling through to chat instead of
showing usage. Match the exact "/md" token in addition to "/md ".

Signed-off-by: Matt Van Horn <mvanhorn@users.noreply.github.com>
Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn mvanhorn force-pushed the feat/8249-md-slash-command branch from 70b57eb to 359a5a8 Compare April 6, 2026 03:16
@mvanhorn
Copy link
Copy Markdown
Contributor Author

mvanhorn commented Apr 6, 2026

Signed both commits and force-pushed. Also added a fix for bare /md (without a trailing space) falling through to chat instead of showing usage.

Good to know about the ui/text move for the TUI. Happy to port this there if that's the preferred path, or keep it in the current CLI layer if it still makes sense here.

@DOsinga
Copy link
Copy Markdown
Collaborator

DOsinga commented Apr 6, 2026

Hey @mvanhorn, thanks for the contribution! I'm going to close this one out for a couple of reasons:

  1. Multiple open PRs: It looks like you have 5 open PRs with none merged yet — our contributing guide asks that first-time contributors wait for earlier PRs to land before opening more, so reviewers can give each one proper attention. See: https://github.com/block/goose/blob/main/CONTRIBUTING.md#pull-requests

  2. Feature direction: After some discussion we've decided we don't really need a /md slash command in goose right now, so we're also closing the linked issue.

We really do appreciate you taking the time to contribute though! If you'd like to keep working with us, we'd suggest picking one of your existing PRs to focus on and we can go from there. 🙏

@DOsinga DOsinga closed this Apr 6, 2026
@mvanhorn
Copy link
Copy Markdown
Contributor Author

mvanhorn commented Apr 7, 2026

Totally fair, thanks for explaining. I'll focus on getting #8271 across the line first and pace future submissions better.

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.

feat: add /md <file> command to render markdown files in CLI

3 participants