Skip to content

feat(mcp): get_why on a directory reports its files' git history - #4356

Merged
swati510 merged 2 commits into
mainfrom
fix/why-directory-history
Oct 22, 2026
Merged

swati510 merged 2 commits into
mainfrom
fix/why-directory-history

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

What

get_why on a directory (for example packages/core/src/repowise/core/policy) returned origin_story: {available: false, summary: "No git history ..."} although every file under it has commits. Git metadata is stored per file, so a directory never matched a row. Multi-target cards had the same false line, and a directory with no decision and no checkout copy was reported as "Path not found".

How

  • A directory's origin story is built from the stored rows of the non-excluded files under it: scope: "directory", files_with_history, first and last commit dates, and the newest stored key commits, each SHA once. No commit count, owner or age is claimed, since per-file totals do not add up to a directory's.
  • Single-path mode and the per-target cards share one helper. The not-found check asks the index for any file under the path with a cheap prefix query before loading rows.
  • A path with no stored rows says "No git history is indexed for X", which is what the index knows, rather than implying the path has no history.
  • Docs: one paragraph under get_why in docs/agent/MCP_TOOLS.md.

Verification

  • Repowise index, packages/core/src/repowise/core/policy: before, "No git history available"; after, 4 files, first commit 2026-10-14, last 2026-10-20, key commits 2f77936, 25bfd42, 2b6e113, 93469aa. git log -- <dir> lists exactly those 4 commits on those dates.
  • Two other indexed open source repositories: a 4-file test directory (dates agree with git log in UTC) and a 73-file package directory (71 files with stored rows, one commit, date agrees).
  • A nonexistent directory still returns "Path not found".
  • Tests: tests/unit/server/mcp 3360 passed, plus directory fixtures for the path mode, target cards, shared-commit dedup, excluded files, sibling prefixes (src/db vs src/dbx) and ./, backslash and root inputs.

Git metadata is stored per file, so a directory target always read "No git
history" and a directory with no decision and no checkout copy read "Path not
found". A directory's origin story is built from the non-excluded files under
it: how many have history, the first and last commit dates, and their stored
key commits once each, with no commit count or owner claimed. A path with no
stored rows says no history is indexed for it.
@RaghavChamadiya RaghavChamadiya changed the title fix(mcp): get_why on a directory reports its files' git history feat(mcp): get_why on a directory reports its files' git history Oct 22, 2026
@swati510
swati510 merged commit 26dbb9c into main Oct 22, 2026
10 checks passed
@swati510
swati510 deleted the fix/why-directory-history branch October 22, 2026 06:47
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.

2 participants