feat(diff-index): add commit diff retrieval surface (#80) - #81
Merged
liplus-lin-lay merged 1 commit intoApr 19, 2026
Merged
Conversation
…tors
commit diff を retrieval surface として追加する。push webhook の commits[] を
iterate し、各 commit について GET /repos/{repo}/commits/{sha} で per-file patch を
取得、1 commit × N files を batch embedding(Workers AI `text: string[]`)で 1 call に
まとめて N vector として Vectorize に upsert する。Option 2b 採択。
- types.ts: DiffRecord / DiffFileStatus を追加、VectorMetadata の type union に
"diff" と commit_sha/file_path/file_status/commit_date/commit_author/
blob_sha_before/blob_sha_after フィールドを optional で拡張。
- store.ts: diffs テーブル(PK = repo, commit_sha, file_path)と CRUD + HTTP
endpoint を追加。resetForReEmbed にも diffs を含める。
- pipeline.ts: generateEmbeddingBatch を新設し batch embed を提供。
processAndUpsertCommitDiff は MAX_EMBEDDING_BATCH_SIZE (=20) で chunk し、
chunk ごとに batch embed -> batch upsert -> DO store 書き込みを行う。
Vector ID = "{repo}#commit-{sha}#file-{base64url(path)}"。binary や
oversized で patch が無い file は skip。
- webhook.ts: handlePushEvent の既存 .md 処理を無改造のまま、同じ commits[]
iterate で fetchCommitDetail -> processAndUpsertCommitDiff を並行呼出し。
1 commit の失敗は他 commit に波及しない。
- mcp.ts: search_issues の type enum に "diff" を追加、diff 結果の URL は
commit page に組み立て、タイトルは "{short-sha} {file_path}"。
list_recent_activity にも commit diff activity を追加。
- docs/0-requirements: .ja.md / .md の両方で新 retrieval surface を反映。
削除済みファイル・非 .md 拡張子の判断履歴が semantic で引けるようになる。
2026-04-19 に `momeri.pal`(削除済み)を引けなかった事例が契機。
本 PR 対象外: 歴史 commit backfill、per-hunk chunking、cost 自動調整、独立 MCP tool。
Closes #80
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
github-rag-mcp | 2958063 | Apr 19 2026, 06:07 AM |
liplus-lin-lay
deleted the
80-enhancement-index-commit-diffs-for-judgment-history-retrieval
branch
April 19, 2026 06:11
This was referenced Apr 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #80
概要
commit diff を semantic 検索可能な retrieval surface として追加しました(Option 2b)。
pushwebhook の commits[] を iterate し、各 commit に対しGET /repos/{repo}/commits/{sha}で per-file patch を取得、1 commit × N files → N vectors を batch embedding(Workers AItext: string[])で 1 call にまとめて Vectorize に upsert します。削除済みファイルや非
.md拡張子(.palなど)の判断履歴も semantic で引けるようになります。契機は 2026-04-19 にmomeri.pal(liplus-language、削除済み)を RAG 経由で届かせられなかった事例です。変更内容
src/types.tsDiffRecord/DiffFileStatus追加、VectorMetadataに diff 用フィールドを optional 拡張(type union に"diff"を追加)src/store.tsdiffsテーブル(PK = repo, commit_sha, file_path)と CRUD + HTTP endpoint。resetForReEmbedにも diffs 含めるsrc/pipeline.tsgenerateEmbeddingBatch追加。processAndUpsertCommitDiffはMAX_EMBEDDING_BATCH_SIZE (=20)で chunk し batch embed → batch upsert → DO store 書き込み。Vector ID ={repo}#commit-{sha}#file-{base64url(path)}。binary / oversized で patch が無い file は skipsrc/webhook.tshandlePushEventの既存.md処理を無改造のまま、同じcommits[]iterate にfetchCommitDetail→processAndUpsertCommitDiffを並行追加。1 commit 失敗は他に波及しないsrc/mcp.tssearch_issuesのtypeenum に"diff"を追加、description 更新、結果 URL は commit page、タイトルは"{short-sha} {file_path}"。list_recent_activityにも diff 追加docs/0-requirements(.ja).md設計選択
MAX_EMBEDDING_INPUT_CHARS (=8000)を流用。embedding input はcommit message + "\n\n" + file path + "\n\n" + patchの先頭 8000 文字。-行に path が出ない場合があるため、意図的に file path を input に inline する。/が含まれるため、+/=を-_+ 空に replace(RFC 4648 §5 相当)。.mdsurface を保持:type: "doc"live index は完全に無改造。diff はtype: "diff"で別 scope。本 PR 対象外(issue 本文の決定通り)
search_diffMCP tool(search_issuesのtype: "diff"filter で足りる想定)検証
npx tsc --noEmitで型チェック通過。npx wrangler deploy --dry-runで bundle success(Total Upload 2142 KiB / gzip 365 KiB)。関連