hermes - ✅(Solved) Fix [Feature]: Introduce /copy for hermes [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#11835Fetched 2026-04-18 05:58:40
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

PR fix notes

PR #12362: feat: support copy command

Description (problem / solution / changelog)

What does this PR do?

<!-- Describe the change clearly. What problem does it solve? Why is this approach the right one? -->

Add /copy support

Related Issue

Fixes #11835

Type of Change

<!-- Check the one that applies. -->
  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

Here are all the changes made for this feature:

Python — Classic CLI

cli.py

  • Added _CODE_BLOCK_RE regex and _extract_code_blocks() helper (line ~119) to parse fenced code blocks from markdown text
  • Modified _write_osc52_clipboard() to try native clipboard (pbcopy/xclip/xsel) first, falling back to OSC 52 only over SSH
  • Added _copy_to_system_clipboard() method — runs pbcopy on macOS, wl-copy/xclip/xsel on Linux via subprocess
  • Rewrote _handle_copy_command() — detects code blocks and delegates to the interactive picker when present
  • Added _copy_with_picker() — builds picker labels from code blocks and calls curses_copy_picker
  • Added _copy_text_to_clipboard() — extracted clipboard copy + confirmation message
  • Added _write_copy_to_file() — prompts for file path (with smart extension default) and writes selected content

hermes_cli/curses_ui.py

  • Added curses_copy_picker() — curses-based single-select with Enter (copy) / w (write to file) / Esc (cancel)
  • Added _copy_picker_numbered_fallback() — text-based fallback for non-curses terminals

hermes_cli/commands.py

  • Updated CommandDef description for /copy to mention the interactive picker

TypeScript — TUI (Ink)

ui-tui/src/app/interfaces.ts

  • Added CopyPickerState and CopyPickerItem interfaces
  • Added copyPicker: CopyPickerState | null to OverlayState

ui-tui/src/app/overlayStore.ts

  • Added copyPicker: null to default overlay state
  • Included copyPicker in the $isBlocked computed store

ui-tui/src/app/useInputHandlers.ts

  • Added keyboard handling for the copy picker overlay (up/down/Enter/w/Esc)

ui-tui/src/components/appOverlays.tsx

  • Added copy picker rendering inside FloatingOverlays with cursor highlight
  • Updated hasAny guard to include copyPicker

ui-tui/src/app/slash/commands/core.ts

  • Enhanced /copy run handler to extract code blocks and open the picker overlay when blocks are present

ui-tui/src/lib/text.ts

  • Added CodeBlock interface and extractCodeBlocks() function

Tests

tests/cli/test_cli_copy_command.py

  • Updated existing tests to use _copy_to_system_clipboard mock instead of _write_osc52_clipboard
  • Added test_copy_falls_back_to_osc52_when_native_unavailable
  • Added test_extract_code_blocks_finds_fenced_blocks, test_extract_code_blocks_no_lang_defaults_to_text, test_extract_code_blocks_returns_empty_for_no_blocks
  • Added test_copy_opens_picker_when_code_blocks_present, test_copy_no_picker_when_no_code_blocks
  • Added test_copy_with_picker_copies_full_response, test_copy_with_picker_copies_specific_block, test_copy_with_picker_cancel, test_copy_with_picker_write_to_file
  • Added test_curses_copy_picker_fallback_non_tty
  • Added test_system_clipboard_uses_pbcopy_on_macos, test_system_clipboard_skipped_over_ssh

How to Test

<!-- Steps to verify this change works. For bugs: reproduction steps + proof that the fix works. -->
● how are you
────────────────────────────────────────


╭─ ⚕ Hermes ───────────────────────────────────────────────────────────────────────────────────────────────╮
    I’m running smoothly—just a bunch of code eager to help you. How can I assist you now?
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯

⚙️  /copy
  Copied assistant response #5 to clipboard
 ⚕ gpt-oss:20b │ 15.9K/131.1K │ [█░░░░░░░░░] 12% │ 7m

Checklist

<!-- Complete these before requesting review. -->

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: <!-- e.g. Ubuntu 24.04, macOS 15.2, Windows 11 -->

Documentation & Housekeeping

<!-- Check all that apply. It's OK to check "N/A" if a category doesn't apply to your change. -->
  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

<!-- Only fill this out if you're adding a skill. Delete this section otherwise. -->
  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

<!-- If applicable, add screenshots or log output showing the fix/feature in action. -->

Changed files

  • cli.py (modified, +146/-4)
  • hermes_cli/commands.py (modified, +1/-1)
  • hermes_cli/curses_ui.py (modified, +130/-0)
  • tests/cli/test_cli_copy_command.py (modified, +196/-6)
  • ui-tui/src/app/interfaces.ts (modified, +11/-0)
  • ui-tui/src/app/overlayStore.ts (modified, +3/-2)
  • ui-tui/src/app/slash/commands/core.ts (modified, +22/-1)
  • ui-tui/src/app/useInputHandlers.ts (modified, +25/-0)
  • ui-tui/src/components/appOverlays.tsx (modified, +26/-1)
  • ui-tui/src/lib/text.ts (modified, +17/-0)
RAW_BUFFERClick to expand / collapse

Problem or Use Case

Same as claude code /copy https://code.claude.com/docs/en/commands

Proposed Solution

Copy the last assistant response to clipboard. Pass a number N to copy the Nth-latest response: /copy 2 copies the second-to-last. When code blocks are present, shows an interactive picker to select individual blocks or the full response. Press w in the picker to write the selection to a file instead of the clipboard, which is useful over SSH

Alternatives Considered

No response

Feature Type

CLI improvement

Scope

None

Contribution

  • I'd like to implement this myself and submit a PR

Debug Report (optional)

extent analysis

TL;DR

Implement a feature to copy the Nth-latest assistant response to the clipboard, with an interactive picker for code blocks and an option to write to a file.

Guidance

  • To start implementing this feature, define the command syntax and parameters, such as /copy N, where N is the position of the response to copy.
  • Determine how to store and access previous assistant responses to allow for copying of the Nth-latest response.
  • Consider using a library or module for handling clipboard interactions and file writing.
  • Develop an interactive picker for selecting individual code blocks or the full response when code blocks are present.

Example

No code example can be provided without more context on the existing codebase and technologies used.

Notes

The implementation details may vary depending on the programming language, framework, and existing architecture of the application.

Recommendation

Apply workaround: Implement a basic version of the /copy command with the described functionality to test and refine the feature before fully integrating it into the application.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING