fix(search): gitea_code_search returns only filenames, repeated, without line numbers or snippets #27
Labels
No labels
area/dsh
area/forgejo
experiment
priority/later
priority/next
priority/now
type/bug
type/task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
dsh-plugins/dsh-gitea#27
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
gitea_code_searchreturns only file paths, repeated once per match, with no line numbers and no match text. The handler already produces{path, line, text}rows, but the formatter dropsline/text, so the tool cannot be used to find code.Repro
A no-match search renders
No results.correctly.Observed vs expected
limitbehaves per file (git grep --max-count) rather than globally.lib/handlers/formatters.js:71: export function formatToolResult(...), capped globally bylimitwith a visible footer.Root cause
lib/handlers/repos.jsmaps matches to{ path, line, text }.lib/handlers/formatters.jsgeneric array branch:drops
lineandtext. The handler passes--max-count=${limit}to git grep, which limits matches per file, not in total.Proposed fix
Add a
gitea_code_searchformatter emittingpath:line: text(single-line clipped text), apply a global row cap + footer, and make the handler stop afterlimittotal matches (or documentlimitas per-file). Add formatter tests for the three row shapes (path/line/text,raw, empty).Acceptance: matches show file, line and snippet; total rows never exceed the requested limit; duplicates only for genuinely repeated matches at different lines.
Duplicate check
Searched
search(state all) — no code-search issue; the brief notesgitea_code_searchruns localgit grepby design, which is not the problem.Layer
dsh-gitea plugin/tool (handler + formatter).
Fixed in
56f41de(PR #41).gitea_code_searchnow emitspath:line: snippetper match. The handler caps matches globally (it previously passed--max-counttogit grep, which is per file) and returns{items,total_count,truncated,limit}; the formatter adds… showing N of M matches.Live:
q:"formatToolResult", limit:5→ fivepath:line:rows +… showing 5 of 26 matches.Tests:
test/qa-formatters.test.mjs.