Fix the main-module guard that made every script a no-op on Windows
Today's work on the BRD service, in nine self-contained commits.
Two silent failures. npm run sync had been exiting 0 without doing anything
for eleven days — import.meta.url is a URL and process.argv[1] is a native
Windows path, so the main-module guard could never be true. And a server started
on an occupied port logged "listening" and exited 0 while the old process kept
serving it. On this stack, exit 0 and a cheerful log line are not evidence that
anything happened.
Two gaps closed. Scheduled sync (sync then embed, overlapping runs skip,
GET /api/sync/status) and tombstone reconciliation — the only data-removing
path here, so it is off by default, dry-run unless --apply, and refuses after a
partial sync, on an unreachable doctype, or past a delete-ratio ceiling.
Client attribution. 16 projects moved off the Extension Technologies override to their real ERPNext Customer, backed by exact-match evidence. A Kohler-scoped retrieval now returns Kohler's own history where it previously returned none. 14 ambiguous ones are parked with their candidates recorded rather than guessed.
New surface. packages/brd-mcp exposes the knowledge base over MCP —
kb_search, kb_ask, kb_stats. Scope is fixed at startup and merged last into
every filter, so a tool argument can narrow the search and never widen it; the
server refuses to start unscoped. Plus POST /api/ideas/expand, which drafts the
interview form from a one-line idea and fills only empty fields.
Tests: 1,048 pass / 0 fail.