Skip to content

add write tool formatters#1017

Open
LasmarKhalifa wants to merge 1 commit into
06-30/pi-tool-formatter-readfrom
06-30/pi-tool-formatter-write
Open

add write tool formatters#1017
LasmarKhalifa wants to merge 1 commit into
06-30/pi-tool-formatter-readfrom
06-30/pi-tool-formatter-write

Conversation

@LasmarKhalifa

@LasmarKhalifa LasmarKhalifa commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes #1025

LasmarKhalifa commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-write branch from bee016d to 852ae68 Compare July 2, 2026 16:01
@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-write branch from 852ae68 to f2399f0 Compare July 3, 2026 14:50
@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-read branch from af63b1e to 1522547 Compare July 3, 2026 14:50
@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-write branch from f2399f0 to 4166e5d Compare July 3, 2026 15:30
@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-read branch from 1522547 to 2162423 Compare July 3, 2026 15:30
@LasmarKhalifa LasmarKhalifa marked this pull request as ready for review July 3, 2026 16:30

@mathiusj mathiusj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

write formatter — one inconsistency with the sibling formatters.

lines = content.to_s.lines
preview = truncate(lines.first.to_s.strip)
count = lines.length
"WRITE #{path} \"#{preview}\" (+#{count} #{"line".pluralize(count)})"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

format_write has no bare-name fallback and interpolates path untruncated — unlike every sibling. format_bash/format_ls/format_read degrade to "BASH"/"LS"/"READ" when the key is absent and run path through truncate. This line renders unconditionally, so no-args produces WRITE "" (+0 lines) (double space, empty quotes), and a long path blows the one-line goal since it isn't truncated. Suggest guarding the bare case and wrapping path in truncate to match the others.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the fallback for nil paths, but the path should not be truncated. Some tools truncate the command or other values, such as BASH and LS, but the path should remain fully present so that users can easily access the items that were modified. This mirrors the Claude side of tool formatters.

@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-read branch from 2162423 to 9774c62 Compare July 10, 2026 15:23
@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-write branch from 4166e5d to 1d5f2cb Compare July 10, 2026 15:23
@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-read branch from 9774c62 to eecfae1 Compare July 10, 2026 15:50
@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-write branch 3 times, most recently from 0c38e90 to 5e31fef Compare July 10, 2026 16:33
@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-read branch from eecfae1 to daeaf21 Compare July 10, 2026 16:38
@LasmarKhalifa LasmarKhalifa force-pushed the 06-30/pi-tool-formatter-write branch from 5e31fef to 32856c2 Compare July 10, 2026 16:38
@LasmarKhalifa LasmarKhalifa requested a review from mathiusj July 10, 2026 18:14
@LasmarKhalifa LasmarKhalifa linked an issue Jul 13, 2026 that may be closed by this pull request
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.

Pi format_write tool implementation

2 participants