serena icon indicating copy to clipboard operation
serena copied to clipboard

Feature request: Add tools for moving code

Open KelvinChung2000 opened this issue 5 months ago • 2 comments

Instead of just reading the symbol information, sometimes it is more desirable to copy a code section than to paste. This is useful for refactoring tasks, which involve copying and pasting code from one file to another or moving a section of code into a function. The main benefits will be a lower chance of the LLM hallucinating the code during code movement.

A side benefit, I suppose, is that it can reduce the number of output tokens, since now a code movement turns from reading and writing the same thing to a single tool call.

KelvinChung2000 avatar Jul 14 '25 10:07 KelvinChung2000

Agreed. I think we should add this.

opcode81 avatar Jul 14 '25 11:07 opcode81

On second thought, a pure copy function is perhaps not the ideal supplement. The typical use cases will be

  • to copy & modify (e.g. similar class implementation)
  • to copy & delete (i.e. move) & update references.

For the former case, the copy operation is not helpful (as the modifications could directly be inserted by the LLM in a single step). For the latter case, perhaps a dedicated "move" tool would be better.

opcode81 avatar Jul 14 '25 20:07 opcode81