add grep tool formatters#1019
Conversation
|
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
2d3ce63 to
7730ee2
Compare
3b64e5c to
10a0676
Compare
7730ee2 to
676a57b
Compare
3799ee2 to
919a175
Compare
mathiusj
left a comment
There was a problem hiding this comment.
grep formatters are the most heuristic in the stack — a couple of notes.
| #: () -> String | ||
| def format_grep | ||
| lines = content.to_s.lines.map(&:strip).reject(&:empty?) | ||
| matches, notes = lines.partition { |line| line.match?(%r{\A\S+/}) || line.match?(/\A(?:\S+:)?\d+:/) } |
There was a problem hiding this comment.
Match/note heuristic is best-effort and will miscount. %r{\A\S+/} treats any line starting with a non-space run + / as a match, and \A(?:\S+:)?\d+: as a line-number hit. Real grep hits that don't carry a path/line prefix (e.g. grep -h, or matched content that doesn't fit either shape) get bucketed as notes and undercount; conversely a note containing an early / counts as a match. Since "3 matches" is shown to the user, a wrong count is a visible lie. It won't break anything, but please add a comment that this depends on Pi's grep output format and is intentionally approximate — so nobody later trusts the count as exact or "fixes" it by tightening the regex without knowing the contract.
There was a problem hiding this comment.
The matching was actually done against logs on the Claude side that spanned over a hundred calls to grep! The current matching got it all right, so I actually expect this to be accurate. My suggestion is to keep this as it is and if we ever notice inaccuracies we can always follow up. What do you think?
676a57b to
6401f99
Compare
2ad8c53 to
74166f6
Compare
6401f99 to
27d834e
Compare
74166f6 to
f877583
Compare
27d834e to
9f3ab5a
Compare
f877583 to
f55f3f1
Compare
9f3ab5a to
a161e59
Compare
f55f3f1 to
d0bc73d
Compare
a161e59 to
a785239
Compare
d0bc73d to
5beb941
Compare
a785239 to
d3310c0
Compare
5beb941 to
c15e82c
Compare

Closes #1027