Skip to content

Conversation

KeremTurgutlu
Copy link

@KeremTurgutlu KeremTurgutlu commented Sep 25, 2025

This PR updates read_msg_ to support line numbers and range selection, and implements msg variants of the file edit tools:

  • msg_insert_line_
  • msg_str_replace_
  • msg_strs_replace_
  • msg_replace_lines_

This PR depends on the solveit PR: https://github.com/AnswerDotAI/solveit/pull/926

Here is a minimal dialogue showcasing the new tools

@KeremTurgutlu KeremTurgutlu changed the title text edit tools for msgs Text edit tools for msgs Sep 29, 2025
@KeremTurgutlu KeremTurgutlu marked this pull request as ready for review September 29, 2025 00:42
# %% ../nbs/00_core.ipynb
def msg_insert_line(
msgid:str, # Message id to edit
insert_line: int, # The line number after which to insert the text (0 for beginning of file)
Copy link
Author

@KeremTurgutlu KeremTurgutlu Sep 29, 2025

Choose a reason for hiding this comment

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

Using the same param comment from claude official docs for docments.

Comment on lines +347 to +349
- To get the exact message use `n=0` and `relative=True` together with `msgid`.
- To get a relative message use `n` (relative position index).
- To get the nth message use `n` with `relative=False`, e.g `n=0` first message, `n=-1` last message.
Copy link
Author

@KeremTurgutlu KeremTurgutlu Sep 29, 2025

Choose a reason for hiding this comment

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

With many different ways to read msgs, this should hopefully guide AI on how to call the read_msg tool properly for a given use case.

- &`msg_str_replace`: Find and replace text in a message.
- &`msg_strs_replace`: Find and replace multiple strings in a message.
- &`msg_replace_lines`: Replace a range of lines in a message with new content.
- Always first use `read_msg( msgid=msgid, n=0, relative=True, nums=True)` to view the content with line numbers.'''
Copy link
Author

@KeremTurgutlu KeremTurgutlu Sep 29, 2025

Choose a reason for hiding this comment

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

Here we instruct AI to first read_msg with nums=True before using msg_replace_lines so that it can see the line numbers before setting the start and end line numbers.

@KeremTurgutlu KeremTurgutlu requested a review from jph00 September 29, 2025 10:36
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.

1 participant