Skip to content

Expose Hunk selections to coding agents, with exact text selection when possible #114

@benvinegar

Description

@benvinegar

Problem

Hunk should make it easy to hand the currently relevant diff context to a coding agent.

The user request here is broader than "export the focused hunk": ideally, if the user selects text in Hunk, that selection should become available to their coding agent. At minimum, Hunk should have a first-class way to publish the current hunk/selection to an external agent workflow.

Related work already in flight

There are already open PRs that appear to cover important pieces of this:

From those PR descriptions:

That looks like good foundation work, but there is not yet a clear issue tracking the end-user capability we want to ship.

Goal

Let Hunk publish the user's current review context to a coding agent in a structured, low-friction way.

Potential levels of support:

  1. focused hunk export
  2. published selection export (p-style explicit action)
  3. exact text selection export when terminal selection support makes that possible

Scope / design questions

  • Should Hunk bless the file bridge (.hunk/pi-selection.json), the session CLI + notify stream, or both?
  • Should the integration be Pi-specific or generic enough for any local coding agent?
  • Is the primary UX:
    • explicit publish (p)
    • always-current focused selection
    • both?
  • If arbitrary text selection is not practical cross-terminal, is the focused hunk the right stable primitive to ship first?

Acceptance criteria

  • A user can publish the current review context from Hunk to a coding agent workflow without copy/paste.
  • The exported payload includes enough structure to be useful:
    • repo root (when available)
    • file path / previous path
    • hunk or selection range
    • diff snippet / patch
    • human-readable prompt text
  • The transport is documented and stable enough for external tooling to rely on.
  • If exact text selection is not supported initially, document that the first shipped unit is the focused/published hunk.

Notes

This issue is intentionally outcome-focused so the work can reuse or supersede #73 / #77 as needed without losing sight of the user-facing goal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentsAgent-to-hunk communication (MCP, selections, comments)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions