Files
mcpedia/scripts/indexer.ts
T
asepharyana 8f2229d447 feat(mcpedia): Phase 3 — async indexing (BullMQ), git-sync webhook, revisions, MCP Resources
- packages/queue: ioredis singleton + BullMQ Queue/Worker (prefix mcpedia:
  on shared imrnes Redis :6379); apps/worker runs startWorker()
- @mcpedia/core: indexContentFile/runFullIndex (single indexing entry point
  shared by script/worker/hook) + revision.service (list/get/restore)
- document_revisions table (migration 0002) — snapshots only on body change
- apps/api: POST /hooks/reindex + /hooks/index webhooks; tRPC revisions,
  getRevision, restoreRevision, jobStatus, queueStatus
- apps/mcp: register MCP Resources mcpedia://docs{/,+slug/chunks/revisions}
  ({+slug} RFC6570 reserved expansion for slugs containing /)
- apps/mcp zod pinned to ^4 to match MCP SDK 1.30 compiled types
  (resolves registerTool TS2589/ShapeOutput skew)
- scripts/enqueue.ts one-shot job enqueue helper; indexer refactored to runFullIndex
- PHASES.md/README/.env.example/docs updated
2026-08-19 20:18:28 +07:00

20 lines
616 B
TypeScript

import { runFullIndex } from "@mcpedia/core";
// Phase 3: the indexer now goes through `runFullIndex`, the single indexing
// entry point shared with the BullMQ worker and the git-sync hook. It parses
// each content file, upserts `documents`, chunks+embeds, and snapshots a
// revision when the body changed.
async function main() {
const reason = process.argv[2] && process.argv[2].startsWith("--reason=")
? process.argv[2].slice("--reason=".length)
: "index";
await runFullIndex(reason);
}
main()
.then(() => process.exit(0))
.catch((err) => {
console.error(err);
process.exit(1);
});