Skip to content

feat: index GitHub Wiki content into RAG (W4, patch) - #129

Merged
liplus-lin-lay merged 1 commit into
mainfrom
128-feat-index-github-wiki-content-into-rag-w4
Apr 25, 2026
Merged

liplus-lin-lay merged 1 commit into
mainfrom
128-feat-index-github-wiki-content-into-rag-w4

Conversation

@liplus-lin-lay

Copy link
Copy Markdown
Member

概要

GitHub Wiki コンテンツを github-rag-mcp の RAG index に取り込む新規 ingestion 経路を追加。`mcp__github-rag-mcp__search` で wiki ページが他 surface と同列に検索結果に出る。Liplus-Project/liplus-language で進行中の判断記録 wiki 寄せ運用の前提条件。

設計判断(事前 lock 済み)

# 軸 採用
1 取り込み範囲 wiki がサポートする text-based 全種 (md / markdown / mediawiki / org / rst / rest / textile / pod / asciidoc / creole)
2 type 表現 新 type `wiki_doc`(既存 `doc` と並列、同名でも別ヒット)
3 対象 repo 既存 `POLL_REPOS` 自動。wiki 存在は `{repo}.wiki.git/info/refs?service=git-upload-pack` で 200 検出、404 = skip
4 poll 頻度 独立 cron `45 * * * *` (light :00 / comments :15 / diffs :30 と staggered)
5 conflict docs/ と wiki 両方 index、type で区別
6 include_content wiki page から raw URL fetch (`raw.githubusercontent.com/wiki/{repo}/master/{page}.{ext}`)
7 result URL `https://github.com/{repo}/wiki/{page-name}\`
8 wiki repo 認識 smart-HTTP info/refs 200/404
9 バージョン patch (v0.8.4)、v0.x 初期で `Anything may change`
10 既存 entry 移管 W4 release 後に liplus-language 側で別 PR

変更内容

Worker side:

  • `src/types.ts` — `WikiDocRecord` interface + `VectorMetadata.type` 拡張 + `wiki_path` / `wiki_extension` 追加
  • `src/store.ts` — DO SQLite `wiki_docs` table + idempotent CREATE + CRUD アクセサ + HTTP handler 4 種 (`/upsert-wiki-doc` / `/wiki-doc` GET/DELETE / `/wiki-docs` / `/recent-wiki-docs`)
  • `src/pipeline.ts` — `wikiDocVectorId` (prefix `w`) + `processAndUpsertWikiDoc` + `sha256Hex` helper export
  • `src/poller.ts` — `wikiExists` (smart-HTTP probe) / `listWikiPages` (`_pages` HTML scrape) / `fetchWikiContent` (拡張子 probe + 前回ヒット拡張子 cache) / `pollWiki` + `WIKI_CRON` dispatch
  • `src/mcp.ts` — type filter enum 拡張 / scan mode wiki block / search mode metadata mapping / URL builder / title 補完 / `inlineDocContent` を doc + wiki 並列 fetch に拡張
  • `wrangler.toml` — crons に `45 * * * *` 追加

Schema impact:

  • D1 `search_docs` 既存カラム再利用(migration 不要、`type='wiki_doc'` + `doc_path` を page slug に流用)
  • DO IssueStore `wiki_docs` 新規 table、`CREATE TABLE IF NOT EXISTS` で既存データ保護
  • Vectorize は新 metadata 受け入れ可、schema 変更不要

Docs:

  • `docs/0-requirements{.md,.ja.md}` — Cron Poller 4 triggers / wiki poller 専用節 / type enum / Structured State Store 棚卸し更新
  • `README{.md,.ja.md}` / `mcp-server/README.md` / `mcp-server/manifest.json` — surface coverage / tool description 更新

テスト

  • `tsc --noEmit -p tsconfig.json` exit 0
  • `mcp-server/npm test` (= `node --check server/index.js`) pass
  • 新規 unit test なし — wiki ingestion は integration-bound(live HTML scrape + raw fetch)、deploy 後の本番 cron で動作観測する設計

既存ingestion経路への影響

ゼロ。すべて additive:

  • types.ts: union 末尾に追加のみ、既存 type 列挙は変えてない
  • store.ts: 既存 doc handler 群は触らず、新 `/wiki-doc` 系 endpoint を追加
  • pipeline.ts: 既存 `processAndUpsertDoc` は触らず、並列の `processAndUpsertWikiDoc` 追加
  • poller.ts: 既存 light/comments/diffs cron は無修正、`WIKI_CRON` のみ新規 dispatch 分岐
  • mcp.ts: 既存 result mapping は no-op pass through、wiki_doc rows のみ新 branch
  • wrangler.toml: 4th cron 追加のみ

バージョン

patch (v0.8.4 milestone)。v0.x 初期開発期で additive なので minor bump せず patch 据え置き。

関連

Adds a new ingestion surface for GitHub Wiki pages so the unified `search`
tool can return wiki content alongside repository docs / issues / PRs / etc.
Driven by the liplus-language move toward wiki-only judgment records — without
this, migrated `docs/[a-z].-*.md` decision-log entries would disappear from
RAG search after migration.

Design choices (locked in advance with Master):
- Coverage: every text-based wiki extension supported by GitHub (md /
  markdown / mediawiki / org / rst / rest / textile / pod / asciidoc / creole)
- Type representation: new `wiki_doc` type (parallel to existing `doc`,
  not a sub-flavour of it; same-name page in both surfaces returns two hits)
- Repo selection: every repo in POLL_REPOS automatically; wiki existence
  detected per-repo by probing `{repo}.wiki.git/info/refs?service=git-upload-pack`
  (200 = ingest, 404 = skip)
- Cron: independent slot at `:45 * * * *` (siblings: light :00 / comments
  :15 / diffs :30) so the new surface gets its own per-Worker subrequest budget
- Conflict policy: docs/ and wiki are both indexed and surfaced; the row's
  `type` field discriminates
- Page enumeration: HTML-scrape `/{repo}/wiki/_pages` (no public REST API
  for wiki content); per-page extension probed by URL fallback chain and
  cached on the WikiDocRecord for subsequent polls
- Change detection: SHA-256 of raw content (no git blob SHA without the wiki
  git smart-HTTP protocol)

Worker side:
- src/types.ts        — new WikiDocRecord, type union extension, wiki_path /
                        wiki_extension VectorMetadata fields
- src/store.ts        — wiki_docs SQLite table + idempotent CREATE in
                        initSchema + upsert / get / list / recent / delete
                        accessors + HTTP handlers (/upsert-wiki-doc /
                        wiki-doc / wiki-docs / recent-wiki-docs)
- src/pipeline.ts     — wikiDocVectorId (prefix "w") + processAndUpsertWikiDoc
                        + sha256Hex helper exported for poller reuse
- src/poller.ts       — wikiExists / listWikiPages / fetchWikiContent /
                        pollWiki + WIKI_CRON dispatch + runWikiSurface
- src/mcp.ts          — type filter enum extended to include "wiki_doc";
                        scan-mode wiki block; search-mode metadata mapping
                        (wiki_path / wiki_extension); URL builder branch
                        producing https://github.com/{repo}/wiki/{page};
                        title enrichment for wiki rows; inlineDocContent
                        extended to fetch wiki raw markup (parallel to docs)
- wrangler.toml       — crons append "45 * * * *"

Schema impact:
- D1 search_docs reuses existing columns (no migration); rows carry
  `type='wiki_doc'` and use `doc_path` to store the wiki page slug.
- DO IssueStore adds wiki_docs table on next access (CREATE IF NOT EXISTS,
  no migration needed; existing data preserved).
- Vectorize accepts the new metadata fields without schema change.

Docs:
- docs/0-requirements{.md,.ja.md} — Cron Poller section bumped to four
  triggers, dedicated wiki-poller subsection, type enum expanded,
  Structured State Store inventory updated
- README{.md,.ja.md}, mcp-server/README.md, mcp-server/manifest.json —
  surface coverage + tool description updated

Tests:
- tsc --noEmit on src/ passes (exit 0)
- mcp-server `node --check server/index.js` passes
- No new automated tests added — wiki ingestion is integration-bound (live
  HTML scrape + raw content fetch) and exercised in production after deploy

v0.x patch under "Anything may change" — additive new surface, existing
ingestion paths untouched.

Closes #128
@liplus-lin-lay liplus-lin-lay linked an issue Apr 25, 2026 that may be closed by this pull request
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
github-rag-mcp 5b05bd0 Apr 25 2026, 05:33 PM

@liplus-lin-lay liplus-lin-lay left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI 自己レビュー (auto, patch)

仕様適合

  • #128 の design choice 10 軸すべて反映確認 (拡張子全種 / 新 type / 全 repo 自動 / 独立 cron / 両 index / raw fetch / wiki URL / smart-HTTP probe / patch / W4 後別 PR)
  • target_files 全 9 ファイルすべて touched
  • 既存 doc / issue / PR / release / diff / comment ingestion 経路は完全に無修正、追加のみ

内容整合

  • D1 schema は migration なしで type='wiki_doc' row を受け入れる前提を確認 (既存 search_docs テーブルは type 列に CHECK 制約なし)
  • DO wiki_docs テーブルは CREATE TABLE IF NOT EXISTS、既存 instance の next access で created、既存データ無破壊
  • tokenizerKindForType 既定 nat 経路に乗るため新 type も問題なし
  • Vectorize metadata は keys 自由なので新 wiki_path / wiki_extension 受け入れ可
  • vector ID prefix は w: で既存 d: / r: / c: / ic: / pv: / pc: と衝突なし

TypeScript / build

  • tsc --noEmit -p tsconfig.json exit 0
  • mcp-server node --check server/index.js pass
  • Cloudflare Workers Builds CI も pass

自己リスク申告

  • HTML scrape の脆弱性: /{repo}/wiki/_pages の HTML 構造は GitHub UI 変更に依存。link href shape が変わると enumeration が静かに 0 件に落ちる。tolerant regex で吸収狙いだが、long-term には isomorphic-git or 公式 API への移行が望ましい (現時点では未実装)
  • 拡張子 probe コスト: 初回 page は 10 拡張子試行 (404 確認まで)、bulk import 時に GitHub raw API への fan-out が大きい。次回以降は cached extension を使うので 1 fetch に収まる
  • change detection の精度: SHA-256 content hash だが whitespace / trailing newline 揺れには敏感、git のように tree 整合チェックではない。実用上問題ないが、過剰再 embed の可能性あり
  • 新規 unit test 不足: integration-bound と判断したが、listWikiPages の HTML parse ロジックや wikiExists の status 検出は単体テスト可。後続で追加候補
  • Worker 未 deploy: Cloudflare Workers Builds CI は pass したが、本番 deploy 後に `pollWiki` が初回 cron で正常動作するかは production 観測待ち

判定

auto patch self-review 承認、gh pr merge --squash で進める。本番 deploy 後の最初の :45 cron で wiki 取り込みが動くかを観測する。失敗時は webhook event か log で検知できる構造。

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.

feat: index GitHub Wiki content into RAG (W4)

1 participant