DOCUMENTATION

WhyBase Reference & Architecture

Requirements: Node.js 20.0.0+ and Git. Everything runs 100% locally with zero cloud API keys.

Quickstart

Preview what init will configure before modifying any files using --dry-run:

npx whybase init --all --sync-rules --dry-run

Initialize WhyBase inside any single repository or multi-repo workspace:

cd your-project
npx whybase init --all --sync-rules

Safety guarantees during init:

Using WhyBase in AI Editors

whybase init --all automatically registers MCP targets in .mcp.json, .cursor/mcp.json, .vscode/mcp.json, .windsurf/mcp.json, and ~/.continue/config.yaml. Reload your editor window and ask:

"Why does this lock exist and what breaks if I edit src/billing/webhook.ts?"
"Check fragile zones in this repo before refactoring."
"Record a decision that we must keep LOCK_MS for duplicate Stripe retries."

Language Analysis Depth

WhyBase uses the TypeScript Compiler API for JS/TS and lightweight regex extractors for polyglot repositories:

LanguageParserDependency DepthBlast Radius Depth
TypeScript / JavaScriptTypeScript Compiler APIImports, exports, tsconfig.json paths, workspace packages, route hintsFile-level + Symbol-level callers
PythonRegex AST extractorRelative/module imports, from ... import symbols, FastAPI route hintsFile-level + Symbol regex callers
Go / PHP / Rust / JavaRegex extractorgo.mod modules, PSR-4 composer.json, crate::, Java package importsFile / Module-level only (no cross-file symbol graph yet)

Hotspot Heuristic & Tuning

Fragile zone scoring uses a commit-message keyword heuristic (fix, bug, hotfix, revert, etc.) weighted by commit recency. Because commit subjects like "fix typo" can add noise, you can tune thresholds and keywords directly in .ai-context/config.yaml:

hotspots:
  minScore: 4
  bugFixWeight: 3
  revertWeight: 5
  commitWeight: 0.5
  bugFixKeywords:
    - fix
    - hotfix
    - regression
    - race

Security & Privacy

Visual Knowledge Graph Dashboard

npx whybase ui

Opens http://127.0.0.1:4173 with Explorer & expandable Blast Radius SVG, interactive Dependency Graph, Fragile Zones risk distribution, Decisions & Rules CRUD (with Approve controls for AI drafts), live SSE file-watcher sync, and Click-to-Open IDE.

CLI Commands

CommandPurpose
whybase init [--all] [--local] [--ollama] [--no-hook] [--no-global] [--dry-run] [--sync-rules]Initializes .ai-context/, builds Git + AST graph, registers MCP targets, and installs the post-commit hook.
whybase ui [--port 4173] [--no-open] [--no-watch]Starts the authenticated localhost dashboard with live SSE sync.
whybase watchWatches source files and keeps .ai-context/.cache/graph.json updated live.
whybase sync [--ollama]Incrementally re-scans Git history and AST dependencies via mtimeMs cache.
whybase inspect <file> [--symbol name]Prints Git stats, fragile score, direct callers, symbol callers, and guardrails.
whybase decide "<title>" --rule "..." --context "..." [--paths "..."]Records a human-reviewed ADR Markdown file in .ai-context/decisions/.
whybase rules-sync [--targets cursor,claude,continue,agents]Mirrors rules.yaml and reviewed ADRs into editor rule marker blocks.
whybase hook <install|remove> [--local]Installs or removes the non-blocking Git post-commit auto-sync hook.
whybase pr-check [--base main] [--markdown] [--fail-on-score N] [--max-impact N]Evaluates changed files for blast radius and fragile zone CI gates.
whybase serve [-r path]Starts the MCP server over stdio.
whybase doctor [-r path]Verifies .ai-context/, graph cache, MCP configs, rules, Git hooks, and Ollama.

MCP Tools & Resources

GitHub Actions PR Gate

- name: WhyBase PR Check
  run: npx whybase pr-check --base origin/${{ github.base_ref }} --markdown --fail-on-score 12 --max-impact 25 >> "$GITHUB_STEP_SUMMARY"