Skip to content

Repository files navigation

Manthan

Proactive, corpus-grounded writing surface. Idle-triggered direction plus per-sentence style and fact checks, grounded in the writer's own sources and style exemplars.

This repository is source available, not open source. See LICENSE.md (FSL-1.1-ALv2). Copyright 2026 Shiveena Ventures, LLC.

This repository is a monorepo:

  • backend/ — Go 1.26 platform, domain-driven (documents, coaching, corpus)
  • apps/macos/ — native Mac app (Wails v3 + TipTap)
  • docs/ — architecture and the scaffold spec

Product intent is tracked on Linear team MAN (project). Linear's current milestone is still Disqualify; this tree is the product scaffold, not the one-day throwaway prototype in MAN-1.

Prerequisites

  • Go 1.26+
  • Node.js 22+ (for the Mac frontend)
  • On a Mac: Wails v3 (go install github.com/wailsapp/wails/v3/cmd/wails3@v3.0.0-beta.9)

Run

Session loop

export OPENROUTER_API_KEY=...
go run ./cmd/manthan

HTTP listens on 127.0.0.1:8787. SQLite is data/manthan.sqlite (gitignored). Model is MANTHAN_MODEL (default google/gemini-3.5-flash-lite).

Ingest Markdown, open a draft, attach sources, then analyze one sentence:

curl -s http://127.0.0.1:8787/v1/ingest -d '{"path":"./corpus","role":"source"}'
curl -s http://127.0.0.1:8787/v1/ingest -d '{"path":"./exemplars","role":"exemplar"}'
curl -s http://127.0.0.1:8787/v1/drafts -d '{"title":"Essay"}'
# PUT /v1/drafts/:id with {"revision":1,"markdown":"..."} then attach sourceIds and POST /v1/drafts/:id/analyze

POST /v1/ingest accepts a file or a directory of *.md.

The margin has two triggers. POST /v1/drafts/:id/analyze checks a sentence you submit. POST /v1/drafts/:id/suggest answers a stall: it reads the draft's tail and returns a question, a direction, a counterclaim, and references. Attached sources sharpen the answer; with none attached the coach speaks from model knowledge and the response says so (sourceGrounded: false). The writing surface calls suggest twelve seconds after the last keystroke, and the margin can be muted.

Privacy: source chunks in analyze leave this machine to OpenRouter. Drafts and SQLite stay local. Exemplars may leave if used for style. The only secret is OPENROUTER_API_KEY.

CLI probe

go build -o manthan ./cmd/manthan
# or: go install ./cmd/manthan

manthan ingest --path ./corpus --role source
manthan ingest --path ./exemplars --role exemplar
manthan draft --title Essay
manthan attach --draft ID --source ID
echo 'Cats need taurine in every meal.' | manthan analyze --draft ID

manthan serve is the HTTP listener. manthan --help states the privacy contract.

Platform (Mac app)

Create local configuration and add your OpenRouter key:

cp .env.example .env
# Edit .env and set OPENROUTER_API_KEY.
make platform

make platform loads .env automatically. The API listens on :8080. Set MANTHAN_ADDR to change the address. GET /health reports the active coach and models.

The platform stores data in manthan/manthan.db under the OS configuration directory. Set MANTHAN_DB_PATH to use another path.

Headless coaching (no Mac app)

Use the headless loop to test speed and output quality before frontend work. Start the platform in one terminal:

make platform

Start the headless client in another terminal:

make headless ARGS='-draft ./work/draft.md -sources ./work/sources -exemplars ./work/exemplars'

The draft must be a .md or .markdown file. Source and exemplar directories are optional. The client reads their Markdown files recursively in deterministic order. It replaces changed source files and detaches removed files from that directory. To reuse a saved document, add -document <document-id>. The local and saved drafts must match when the client starts.

The first NDJSON record has type ready and includes the document ID. Each non-command stdin line must contain one completed sentence. The client appends each sentence as a separate Markdown paragraph, saves both copies, and prints one analysis record. Enter :quit to stop.

The client requires the OpenRouter coach. Use -allow-stub only for local tests.

Analysis records include claim-support verdicts (supported, contradicted, or uncertain), citations, and model and latency metadata. The platform sends the sentence, selected source chunks, and attached exemplar excerpts to OpenRouter. Do not attach material that OpenRouter must not receive.

The HTTP analysis call returns one complete response. The current system does not use SSE or WebSocket streaming. NDJSON only frames headless process output.

Mac app (from a Mac, with the platform running):

cd apps/macos
wails3 dev

The editor can also be typechecked on any OS:

make macos-frontend

Tests

make test

Layout

cmd/manthan                  session HTTP (`go run ./cmd/manthan`)
backend/cmd/platform          Mac-app platform on :8080
backend/cmd/coachprobe        headless idle + sentence probe
backend/cmd/headless           interactive Markdown analysis client
backend/internal/*             bounded contexts + adapters
apps/macos                     Wails project
apps/macos/frontend            React + TipTap writing surface

About

Manthan — corpus-grounded writing copilot (source available, FSL-1.1-ALv2)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages