Headless API

# Use Fob as local context infrastructure.

The daemon gives scripts, dashboards, and future MCP tools a local-only API for project memory, decisions, conflicts, handovers, and route jobs.

## Start the daemon

    fob daemon --port 8787
    # Dashboard: http://127.0.0.1:8787
    # API docs:  http://127.0.0.1:8787/api/docs

The daemon binds to `127.0.0.1`. It is local-only unless you intentionally expose it through something like Tailscale.

## CLI context commands

    fob pull "what should the next fix be?"
    fob push --decision "Ship live map mode as an explicit mode, not the default."
    fob push --pin --label map "Imported BRYKK map review."
    fob log
    fob conflicts

## Core endpoints

- `GET /api/status` checks tool availability, context pressure, git state, and stale scan state.
- `GET /api/dashboard` returns the combined dashboard payload.
- `GET /api/memory` returns raw local memory files.
- `GET /api/context?q=<question>` selects relevant saved context without calling a model.
- `GET /api/search?q=<query>` searches memory, decisions, conflicts, pins, current state, and timeline.
- `GET /api/events` streams live dashboard status updates when project files change.
- `GET /api/approvals` lists file-edit approval requests.
- `GET /api/git/diff` returns status, diff stats, staged diff, and working-tree diff.
- `POST /api/save` saves memory, preferences, decisions, conflict resolutions, or pins.
- `POST /api/approvals` creates a file-edit approval request.
- `POST /api/approvals/status` approves, rejects, or reopens a request.
- `POST /api/approvals/patch` attaches a proposed unified diff for review.
- `POST /api/approvals/apply` applies an approved patch after typed confirmation.
- `POST /api/git/commit` stages non-Fob memory files and commits after typed confirmation.
- `POST /api/git/push` pushes clean local commits after typed confirmation.
- `POST /api/action` runs local actions: handover, compact, timeline, or rescan.
- `POST /api/import` imports a prior AI response as reusable context.
- `POST /api/route/start` starts an async route job for Claude, Codex, both, debate, or resolve.
- `GET /api/route/status?id=<job-id>` polls route job progress.

## Example

    curl "http://127.0.0.1:8787/api/context?q=map%20live%20mode"

    curl -X POST "http://127.0.0.1:8787/api/save" \
      -H "Content-Type: application/json" \
      -d '{"kind":"decision","text":"Treat live map as an explicit mode."}'