Skip to content

feat(mcp): add file_history tool with per-file patch events - #192

Merged
samzong merged 1 commit into
mainfrom
feat/mcp-file-history
Aug 29, 2026
Merged

feat(mcp): add file_history tool with per-file patch events#192
samzong merged 1 commit into
mainfrom
feat/mcp-file-history

Conversation

@samzong

@samzong samzong commented Aug 29, 2026

Copy link
Copy Markdown
Owner

What's changed?

  • Add a read-only file_history MCP tool: reports which indexed sessions touched a file, with session id, source, project, title, kind, name, target, event_seq, truncated summary, and event timestamp.
  • Match targets bidirectionally at / or \\ boundaries so relative and absolute forms of the same path find each other.
  • Normalize patch writes into per-file file_write events: Codex apply_patch calls previously produced target-less tool_call events, and OpenCode multi-file patches kept only the first file. Event parser versions bumped (codex 1→2, opencode 2→3) so existing sessions backfill on the next sync.
  • Order events by COALESCE(e.timestamp, s.updated_at, s.started_at) so sources that omit event timestamps (Cursor) still surface by session activity.

Why

  • Agents need a fast answer to "which sessions touched this file" that full-text search cannot express; without the patch normalization the tool would systematically miss Codex file writes, its primary write path.

Verification

  • make check (audit → fmt → clippy -D warnings → workspace tests incl. bench feature) passes.
  • New tests cover bidirectional suffix matching, per-file patch events for Codex and OpenCode, timestamp-less event ordering, limit clamping, and that attrs_json never leaks into tool output.

Add a read-only file_history MCP tool that reports which indexed
sessions touched a file. Targets match bidirectionally at path
separator boundaries, so relative and absolute forms of the same
path find each other.

Normalize patch writes into per-file file_write events: Codex
apply_patch calls previously landed as target-less tool_call events
and OpenCode multi-file patches kept only the first file. Bump both
event parser versions so existing sessions backfill on next sync.

Order events by COALESCE(timestamp, session activity) so sources
that omit event timestamps (Cursor) are not pushed past the limit.

Signed-off-by: samzong <samzong.lu@gmail.com>
@samzong
samzong merged commit f02da0a into main Aug 29, 2026
2 checks passed
@samzong
samzong deleted the feat/mcp-file-history branch August 29, 2026 19:15
@codspeed-hq

codspeed-hq Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 13.35%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 21 untouched benchmarks
⏩ 2 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
export_jsonl 21.4 ms 18.9 ms +13.35%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/mcp-file-history (8b2e343) with main (c4f8af3)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (a45c10e) during the generation of this report, so c4f8af3 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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