Metadata-Version: 2.4
Name: majordomo-cli
Version: 0.3.1
Summary: A personal assistant for your terminal: talks with your dev context loaded, and acts on it
Author: Navaneeth Prabha
License-Expression: MIT
Keywords: assistant,agent,cli,llm,tts,speech,claude-code,github
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.27
Requires-Dist: PyYAML>=6.0
Provides-Extra: nvidia
Requires-Dist: nvidia-riva-client>=2.14; extra == "nvidia"
Provides-Extra: voice
Requires-Dist: sounddevice>=0.4; extra == "voice"
Provides-Extra: documents
Requires-Dist: pypdf>=4.0; extra == "documents"
Requires-Dist: python-docx>=1.1; extra == "documents"
Provides-Extra: tray
Requires-Dist: pystray>=0.19; extra == "tray"
Requires-Dist: Pillow>=10.0; extra == "tray"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: mypy>=1.11; extra == "dev"

# Majordomo

> A majordomo is the head of a household staff who manages everyone and briefs the master.

A personal assistant that runs on your machine, knows what you have been building, and
does something about it. You talk to it, it answers with your context already loaded, and
it can act — read code, write files, run tests — asking before anything changes.

It is **not** a notification relay, and it is **not** a daemon. Your apps already ping you
"PR merged" / "new ticket". Majordomo does the opposite: it digests those streams and
surfaces only what needs a decision, when you ask it to.

## Install

```
uv tool install majordomo-cli
mj
```

`pip install majordomo-cli` works the same way. Either gives you the `mj` command; the
distribution is `majordomo-cli` because `majordomo` is taken on PyPI. Python 3.10+,
Windows first.

The first `mj` configures itself — a model to talk to, and optionally the Claude Code
hooks and a spoken briefing on wake — then drops you into the conversation. Every `mj`
after that just opens it:

```
$ mj
Majordomo. /help for commands, `mj help` for the CLI, /exit to leave.
(6 memories indexed, 2 loaded in full, activity through 2026-09-26)
Last time: 20260926-1431   14 turns  why is the fuser promoting context items

you › ▏
```

Optional extras, none required for text:

| Extra | For |
|---|---|
| `majordomo-cli[nvidia]` | speech, in and out, via NVIDIA Riva |
| `majordomo-cli[voice]` | microphone capture |
| `majordomo-cli[documents]` | text out of PDFs and Word files |
| `majordomo-cli[tray]` | the resident tray icon |

## The door

```
mj                        the conversation. This is the product.
mj help                   list the CLI commands
```

Piped input is answered once and exits, so the door is scriptable:

```
$ echo "what did I ship this week?" | mj
```

Inside the session:

| | |
|---|---|
| `/context` | what memory and activity are loaded, and how large it has grown |
| `/clear` | start fresh, keeping the loaded context |
| `/read PATH` | hand it a document — text, PDF or Word — to talk about |
| `/remember` | propose what from this conversation is worth keeping |
| `/agent TASK` | put the agent to work without leaving the conversation |
| `/continue` | run the last hand-off again, from wherever the agent stopped |
| `/directory [PATH]` | where the agent works; with no path it just tells you |
| `/forget` | delete a saved conversation for good |
| `/build NAME` | scaffold a repo from this conversation |
| `/voice` | dictate your next message — **Ctrl+N** does this any time |
| `/help` | the list |

Chat itself has no tools. `/read` is the one thing that reaches the disk, and what it
reads is fenced as material to discuss rather than instructions to follow; credential
files are refused.

## Commands

The stable set — scripts and the scheduled trigger depend on these:

```
mj brief                  fetch, fuse, print and speak what needs you
mj ask <question>         one question, answered with your context loaded
mj do <task>              the agent works in the current directory
mj chat                   the session, with --resume, --list and --forget
mj config                 what is configured, and which model does what
mj setup                  first-run setup, again
```

`sessions`, `resume`, `review`, `start`, `mic`, `activity`, `remember`, `install-hooks`,
`install-trigger` and `tray` also work, and are deliberately absent from `mj --help`.
Treat them as internal.

```
mj do <task>              the built-in agent works in the current directory
  --directory, -C DIR     work somewhere else
  --yes                   approve every write and command without asking
mj brief
  --no-speak              print only
  --explain               show which model handled each source, and why
mj activity               what you have been doing on GitHub
mj remember <fact>        write a memory; omit the fact to list them
mj sessions               list live / idle / blocked coding sessions
```

## What the agent may do

Nine tools: read, list, grep, write, edit, delete, run a command, **git**, and **GitHub**
via the `gh` CLI. So `mj do "commit this"` and `mj do "open a PR for this branch"` work.

| | |
|---|---|
| runs freely | read, list, grep · `git status`, `log`, `diff --stat` · `gh pr view`, `pr list`, `issue view` |
| shown and confirmed | write, edit, delete, any shell command · `git commit`, `add`, `checkout`, `push` · git commands that print file contents. Answer `a` and that *program* needs no further approval this task |
| asked about again | any command past `brain.agent_command_timeout` (120s) — it is still running while you decide |
| stopped on a budget | any task past `brain.agent_max_steps` (24 model calls) |
| refused outright | credential files · force-pushing · `gh auth`, `gh secret` · a command that only lists, which `list_files` does for free · a write that could not apply, before you are asked about it |

Paths stay confined to the directory you launched from. `--yes` approves every local write
without asking, and still refuses to post to GitHub when stdin is not a terminal.

## Configuration

Every setting has a default, so there is nothing you must write:

```
mj config                     what is in force right now, and why
mj config --list              every setting you can change, with its default
mj config --set KEY=VALUE     change one, without opening the file
mj config --pick ROLE         choose that role's model from what it can actually use
mj config --init              write an annotated ~/.majordomo/config.yml to edit
```

API keys go in `~/.majordomo/.env`. The config file names environment *variables*, never
values, so it stays safe to commit.

Majordomo talks to one OpenAI-compatible `/chat/completions` endpoint, so any provider
speaking that shape works — OpenRouter, OpenAI, Groq, Together, vLLM, or Ollama on your
own machine:

```yaml
brain:
  provider: ollama
  base_url: http://localhost:11434/v1
  api_key_env: ""                 # empty means "needs no key"
  chat_model: qwen2.5:14b
  agent_model: qwen2.5-coder:14b
  fallback_model: ""
```

There are seven model roles, because they want different things:

| Role | Job |
|---|---|
| `worker_model` | compress one source's raw payload |
| `fuser_model` | write the four spoken sentences |
| `reducer_model` | handle a payload too big for the worker |
| `chat_model` | `mj ask`, `mj chat` |
| `agent_model` | `mj do`, `/agent`. Empty reuses `chat_model` |
| `fallback_model` | tried once when a role's model fails |
| `agent_fallback_model` | the same, for the agent only |

The fallback has its own endpoint and key (`fallback_base_url`, `fallback_api_key_env`),
so it can be a second *provider*; empty means inherit the primary's. The shipped
arrangement is OpenRouter primary, NVIDIA fallback, and it costs nothing until you add a
key.

Speech is optional in both directions and off until you have a key. **Ctrl+N** at the
prompt starts dictating; press it again or Enter to stop. NVIDIA is the default both ways;
anything speaking `/v1/audio/transcriptions` works for listening instead
(`voice.asr_provider`).

[majordomo/config.example.yml](majordomo/config.example.yml) explains every setting, and
`mj config` tells you which values are in force and why.

## How it is put together

**The agent is a loop.** It picks the next action from a tool set and keeps going until it
is done or hits a step cap. This is the only place a model decides what happens next — and
therefore the only place with a confirmation gate.

**The briefing is a fixed pipeline.** Workers fetch from each source, a router decides
whether a payload needs reducing first, and a fuser writes the single summary. The code
chooses every step; models only produce text. A failed source degrades to a plain list.

**A conversation is a model, and the terminal is one consumer of it.**
[`session.py`](majordomo/session.py) owns turns, compaction and the file on disk;
[`chat.py`](majordomo/chat.py) owns the loop, the prompt and the keys.

## Development

```
pytest
mypy majordomo
```

The suite covers the safety properties directly — path confinement, the confirmation
gate, what compaction keeps — because those are the parts where being wrong is expensive
rather than merely annoying.

## License

MIT
