Metadata-Version: 2.4
Name: majordomo-cli
Version: 0.3.0
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, and the only command you need

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

`pip install majordomo-cli` works the same way if you would rather. Either gives you
the `mj` command; the distribution is `majordomo-cli` because `majordomo` is taken on
PyPI and `mj` is refused as a project name.

That is the whole thing. The first `mj` configures itself — a model to talk to, and
optionally the Claude Code hooks and a spoken briefing on wake — and then drops you
straight into the conversation. Every `mj` after that just opens it, with a line telling
you what it already knows and where you left off.

```
$ 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 › ▏
```

**Three names, and they differ on purpose.** You install `majordomo-cli`, you type `mj`,
and you import `majordomo`. `majordomo` was taken on PyPI by an unrelated package, and
plain `mj` is refused by it — untaken but not allowed, which the index will only tell you
at upload time. `[project.scripts]` is independent of all that, so the command is one
short word regardless.

`uv tool` (or `pipx`) rather than plain `pip`, because an app installed into whichever
virtualenv happened to be active disappears when you deactivate it. Plain `pip` still
works and is worth using if you want to import from this — `agent.run`, `brief.run`,
`context.build` are real library surface:

```
pip install majordomo-cli
from majordomo import agent, brief, context
```

Python 3.10+. Windows first; nothing is deliberately platform-locked but nothing else is
tested.

### If you would rather not paste an API key

Setup offers a local model instead. If Ollama is running, everything can point at it: no
key, no network, nothing leaving the machine. Slower, and a small model struggles with the
briefing's rules, but it works end to end. See `api_key_env: ""` in the example config.

### Configuration is optional

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

```
mj config                     what is in force right now, and why each value is that
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
mj setup                      go through first-run setup again
```

`--set` edits the line and leaves the rest of the file alone, comments included —
and it refuses a key that does not exist rather than writing one nothing reads:

```
$ mj config --set brain.agent_reasoning=false
brain.agent_reasoning: True -> False
  written to ~/.majordomo/config.yml
  previous version kept as config.20261011-134729.yml.bak

$ mj config --set brain.agent_resoning=false
error: no setting called 'brain.agent_resoning'
  `mj config --list` shows every setting.
```

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

### Choosing your own models

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. Point `brain.base_url` and `brain.api_key_env` at it — and note that naming
either of them also keeps the *fallback* on your provider rather than the shipped one,
because where your requests go is one decision:

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

Nothing leaves the machine there, and nothing in the fallback quietly reaches out either:
a config that names its own provider keeps that choice for the fallback too.

An **empty** `api_key_env` sends no `Authorization` header at all, which is the only
correct spelling for a local server. Naming a variable is a promise that it holds
something, so a name that is unset is still an error — right for a hosted provider, and
exactly wrong for one on your own machine.

Anthropic's own API is not OpenAI-shaped, so reach Claude models through OpenRouter
(`anthropic/claude-sonnet-4.5`) rather than pointing `base_url` at it.

There are **seven model roles**, because they want genuinely different things and one
model is rarely best at all of them:

| Role | Job | Pick it for |
|---|---|---|
| `worker_model` | compress one source's raw payload | speed; the job is mechanical |
| `fuser_model` | write the four spoken sentences | **instruction-following.** It must never turn context into a task |
| `reducer_model` | handle a payload too big for the worker | a long context window |
| `chat_model` | `mj ask`, `mj chat` | consistency — you are waiting on it, so a long tail hurts more than a slow median |
| `agent_model` | `mj do`, `/agent` | tool calling and code. Empty reuses `chat_model` |
| `fallback_model` | tried once when a role's model fails | being on a *different* provider — see below |
| `agent_fallback_model` | the same, for the agent only | tool calling, and low latency — the agent pays it once per step. Empty reuses `fallback_model` |

`fuser_model` is the one worth testing properly. It receives a list of things needing you
and a list of things that don't, and must say "nothing needs you" when the first list is
empty. A model that promotes something from the second list makes the whole tool
untrustworthy — that is the single check to run against any candidate.

#### The fallback is a second provider, not a second model id

`brain` used to have one endpoint and one key, so `fallback_model` was only a different id
sent to the same place. The point of a fallback is surviving one provider having a bad day,
and a request to the same host cannot do that — when OpenRouter answered `400 Provider
returned error`, the "fallback" failed in the same request to the same host.

So the fallback has its own three lines, and **empty means inherit** the primary's:

```yaml
brain:
  fallback_model: nvidia/nemotron-3-ultra-550b-a55b      # no `:free` — see below
  fallback_provider: nvidia
  fallback_base_url: https://integrate.api.nvidia.com/v1
  fallback_api_key_env: NVIDIA_API_KEY
```

That is the shipped arrangement: OpenRouter primary, NVIDIA fallback. Two things about it
are worth knowing.

**It costs nothing until you add a key.** With `NVIDIA_API_KEY` unset the fallback counts
as *not configured* rather than broken — you get your primary's real error plus one line
naming the variable, never "set NVIDIA_API_KEY" in place of the failure that actually
happened. `mj setup` offers to save one; `mj config` shows whether it is there.

**The `:free` suffix is OpenRouter's, not the model's.** The same model NVIDIA serves as
`nvidia/nemotron-3-ultra-550b-a55b` is listed by OpenRouter as
`nvidia/nemotron-3-ultra-550b-a55b:free`. Sending the suffixed id to NVIDIA gets a flat
`404` — which is why a config that already names a `fallback_model` keeps sending it where
it was always sent, and adding `fallback_base_url` is how you opt in to the second
provider.

**The agent gets its own fallback**, because one id cannot serve five roles. The agent's
fallback has to call tools against a 6,209-character schema, up to `agent_max_steps` times
in a task; `worker`, `fuser`, `reducer` and `chat` only have to write prose. Measured on
NVIDIA's endpoint over eight agent-shaped calls each, median round trip:

```text
nvidia/nemotron-3.5-super-vl-120b-a12b    1.0s   shipped as agent_fallback_model
nvidia/nemotron-3-ultra-550b-a55b         1.9s   shipped as fallback_model
mistralai/mistral-large-4-1t-a52b        12.1s
minimaxai/minimax-m3.1-flash            103.0s   unusable, despite the name
```

`agent_fallback_model` is only a model id — it goes to the same `fallback_leg` as
everything else, so there is no fourth endpoint line to set. Leave it empty to use
`fallback_model`, and note that blanking `fallback_model` to switch the fallback off
switches it off for the agent too.

One interaction worth knowing, because it is the same one the `:free` suffix causes.
If your config pins `fallback_model` and names **no** fallback endpoint, your fallback
leg stays on your primary provider — and the shipped `agent_fallback_model` is an id
for NVIDIA's endpoint, which your primary has never heard of. So that default is
dropped for such a config rather than kept, and the agent falls back to the
`fallback_model` you actually named. Naming `agent_fallback_model` yourself always
wins.

#### `mj config --pick` works against whichever provider the field uses

`--pick <role>` asks the registry for the leg that role's requests actually go to, which
for the two fallback roles is your second provider. What it can show depends on what that
provider publishes:

- **OpenRouter** publishes context length, pricing, withdrawal dates and
  `supported_parameters`, so the list is filtered to models the role can actually use and
  each line carries its window, price and expiry.
- **Everyone else** — NVIDIA, Groq, Ollama — publishes `/v1/models` with ids and nothing
  more. There is nothing to filter on, so every id is offered and the picker says so.

Either way **the model you choose is tried once, for real, before it is written.** A
listing is a set of candidates, not a set of answers: on NVIDIA's own 85 ids,
`google/gemma-2b` answers `404 Not found for account`, `nvidia/nemotron-3-embed-1b` is not
on the chat route at all, and `meta/llama-guard-4-12b` answers `400 "auto" tool choice
requires --enable-auto-tool-choice`. For a role that needs tools, a model that replies in
prose is a failure too — which is the case no status code catches.

A rejected pick is named, dropped from the list, and the list comes back.

**The shipped defaults will go stale.** They are OpenRouter *free* model ids, and free ids
appear and vanish. When one does, the failure says which role was pointing at it and which
line to edit rather than leaving you with a 404:

```
No endpoints found for dots-studio/dots-3-note-preview:free
  … was rejected and will keep being rejected. Free model ids come and go, so
  this is usually a shipped default that has aged out rather than anything you did.
  Set by:
    brain.worker_model   compress each source
    brain.chat_model     mj ask, mj chat
  Edit ~/.majordomo/config.yml — `mj config` lists all six roles.
```

Better than hearing about it afterwards: OpenRouter publishes a withdrawal date per
model, and `mj config` shows it beside the role, so a model that is going says so
while there is still time to move.

```
  Models, by role:
    chat      dots-studio/dots-3-note-preview:free   expires 2026-12-31 (80 days)
                mj ask, mj chat
    agent     cohere/north-mini-code:free
                mj do, /agent
```

Nothing is shown for a model with no date, which is most of them — a column saying
"expires: never" on every row teaches you to stop reading it. Under 30 days it says
`EXPIRES in 12 days`.

The same place reports today's free allowance, because on a free tier it is **one pool
shared by every `:free` model on the account**, not a per-model quota — and one agent
step is one request, so a single task can spend a fifth of a day:

```
  free today 0 of 50 requests left  — wait for the reset, or add credits
             shared by every :free model; one agent step is one request
```

Those are OpenRouter's own API, so none of them appears if you point `base_url`
somewhere else — and your model names are never sent to OpenRouter when you do.
`mj config --pick` reads the same registry, so it too is quiet on other providers.

Setup does not ask you to pick models. Choosing between model ids is not a question
anyone can answer in their first minute, and it is the same "know what you want before you
arrive" problem the single front door removes.

That is why the picker is a command rather than a question. `mj config --pick agent` lists
the models that role can *actually* use — tool-calling for the agent, a long window for the
reducer, free first, the one you are already using at the top so Enter changes nothing —
with prices per million tokens and withdrawal dates where the registry publishes them. It
belongs where you have a reason to be choosing, which is not your first minute.

### Three settings worth knowing about

```
mj config --set brain.agent_reasoning=true     let the agent's model think first
mj config --set brain.agent_shell=powershell   what the agent is told it runs
mj config --set brain.agent_command_timeout=600  longer for slow installs
mj config --set brain.chat_compact_threshold_tokens=64000
```

**`agent_reasoning` is off,** and that is measured rather than preferred. Reasoning text
comes out of the same reply budget the answer does, and Majordomo discards it — nothing
reads it. Against `cohere/north-mini-code:free` at a 600-token budget: thinking on spent
717 tokens reasoning and wrote **0 characters** of answer; thinking off wrote 2,541. Both
documented ways of asking a model to think *less* were ignored by the provider. Turn it
back on if the agent's tool choices get worse — that is the trade.

**`agent_shell` is detected,** and only needs setting if the detected answer is not the
one you want described. It is `COMSPEC` on Windows — `cmd.exe`, not PowerShell — and
`/bin/sh` elsewhere, which is not bash. It changes what the model is *told*, not what
runs, so a value that disagrees with the real shell is worse than leaving it empty.

**The compaction thresholds are `0`, meaning "work it out from the model's context
window."** A context window is a fact about your model, so a number written down here
stops being true the next time you change models. Any non-zero value is used exactly as
written. `mj config` says which of the three you are getting:

```
  History folding:
    chat      128,000 tokens
                derived from a 512,000-token window
    agent      60,000 tokens
                set in your config
```

[majordomo/config.example.yml](majordomo/config.example.yml) explains every setting.

### Talking to it out loud

Optional in both directions, and off until you have a key. `mj config` shows where
you stand.

Speech ships pointed at NVIDIA, which does text-to-speech and speech-to-text from
the same endpoint with the same key. Setup asks for it; afterwards it goes in
`~/.majordomo/.env`:

```
NVIDIA_API_KEY=nvapi-...
```

There is a free tier at [build.nvidia.com](https://build.nvidia.com). That gets you
**speaking**. **Listening** needs one more thing, and it is the one piece nothing can
guess for you:

```yaml
voice:
  asr_function_id: "..."   # per model, from that model's page at build.nvidia.com
```

It is an NVCF function id, it is different for every model, and it is a *different
function from the text-to-speech one*. Guessing gets you `DEADLINE_EXCEEDED` or
`INVALID_ARGUMENT`. `mj config` tells you whether it is set.

Then **Ctrl+N** at the chat prompt starts dictating. Press it again — or Enter — to stop,
and the words appear **on the line you were typing**, where you can fix them before a
second Enter sends. `/voice` does the same for the next line, for terminals that swallow
Ctrl+N.

It is push-to-talk on purpose. Recording used to end after 1.8 seconds of quiet, which
cannot tell a thinking pause from a finished sentence — so pausing mid-clause lost the
rest of what you said, with nothing on screen to say so. Nothing but your keypress ends
it now, short of 30 seconds of silence or a 90-second cap. `mj mic` still measures your
microphone, and still reports the pause threshold that applies when nothing is holding
the key.

#### Speech-to-text from somewhere else

NVIDIA speaks gRPC, which is why it is a separate extra. Anything speaking OpenAI's
`/v1/audio/transcriptions` shape works instead, needs no function id, and needs no
extra beyond microphone capture — Groq, OpenAI, or a whisper server on your own
machine:

```yaml
voice:
  asr_provider: openai
  asr_base_url: https://api.groq.com/openai/v1
  asr_api_key_env: GROQ_API_KEY
  asr_model: whisper-large-v3
```

`asr_provider` is separate from `provider` on purpose: speech in and speech out can
come from different places, so a local Whisper can read a cloud voice.

For a local server with no key at all, note *where* the empty key goes:

```yaml
voice:
  api_key_env: ""                        # <- here, not asr_api_key_env
  asr_provider: openai
  asr_base_url: http://localhost:8000/v1
  asr_model: Systran/faster-whisper-small
```

An empty `asr_api_key_env` means "use `api_key_env`", the same way an empty
`asr_provider` means "use `provider`". So blanking the shared one is what says "no
key" — the rule `brain` uses above, reaching speech as well. The one arrangement this
cannot express is a keyless listener beside a keyed speaker.


Optional extras, none required for text:

| Extra | For |
|---|---|
| `majordomo-cli[nvidia]` | speech, in and out, via NVIDIA Riva (gRPC, hence separate) |
| `majordomo-cli[voice]` | microphone capture — the one dependency speech *input* costs |
| `majordomo-cli[documents]` | text out of PDFs and Word files |
| `majordomo-cli[tray]` | the resident tray icon |

Adding one later means reinstalling with it named, e.g.
`uv tool install --force "majordomo-cli[voice]"`. Every "not installed" message tells you the line.

## The door

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

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

```
$ 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 — it inherits what you have been discussing |
| `/continue` | run the last hand-off again, from wherever the agent stopped. Reads the task back out of the durable transcript -- so it survives a compaction -- and needs nothing from the chat model |
| `/directory [PATH]` | where the agent works; with no path it just tells you. The question is asked once per conversation and this is how you change the answer |
| `/forget` | delete a saved conversation for good — picks from the list, then asks (`mj chat --forget` from outside, with or without an id) |
| `/build NAME` | scaffold a repo from this conversation |
| `/voice` | dictate your next message — **Ctrl+N** does this any time, into the line you are typing |
| `/help` | the list |

These are cheap to rename precisely because nobody scripts against them — which is the
other half of why there is one door.

`/read` is the one that reaches the disk from a plain conversation. Chat has no tools by
design, and this is not a hole in that: the agent is confined to a project directory
because a *model* chooses the paths, and here you typed one. What does still apply is the
credential denylist — `.env`, `.ssh/`, `*.pem` are refused, because a read means the
contents reach a model provider — along with the same 8,000-character cap the agent's
reads get, so a long document cannot quietly swallow the conversation.

The document's text is also **fenced**, and this is the part worth knowing. The agent's
file reads come back as `role: "tool"`, a channel the model knows is machine output;
`/read` has no tool call to attach to, so its text can only arrive as a user turn — the
highest-trust channel there is. But "hand it a document" usually means a document somebody
*sent* you, so its author is generally not you. The text is therefore wrapped in
`<<<DOCUMENT name>>>` … `<<<END DOCUMENT>>>`, the system prompt says that region is
material to discuss and never instructions to follow, and three markers are defanged
inside it: the closing fence (a fence a document can close is not a fence), `NEEDS_AGENT:`
(or a document picks the task you get asked to approve) and `REMEMBER:` (or it writes
itself a memory that replays forever).

## Commands

The stable set. Scripts and the scheduled trigger depend on these, so they are the ones
that will not move:

```
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
```

Everything else — `sessions`, `resume`, `review`, `start`, `mic`, `activity`, `remember`,
`install-hooks`, `install-trigger`, `tray` — still works exactly as before and is
documented below, but is deliberately absent from `mj --help`. Treat it as internal: it
may be renamed or moved inside the session without notice.

### Doing things

```
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 review <path>          open Claude Code on a repo with /code-review
mj start <idea>           scaffold a repo, write a brief, open Claude Code
  --dry-run               print what would happen, create nothing
```

The agent has nine tools: read, list, grep, write, edit, delete, run a command,
**git**, and **GitHub** via the `gh` CLI. So `mj do "commit this"`, `mj do "open a PR for this branch"`
and `mj do "what do the comments on PR 12 say?"` all work.

What it may do without asking is the interesting part, because it is not simply "reads":

| | |
|---|---|
| runs freely | read, list, grep · `git status`, `log`, `diff --stat`, branch listings · `gh pr view`, `pr list`, `issue view`, and `gh api` for GET of a *named path* |
| shown and confirmed | write, edit, delete, any shell command · `git commit`, `add`, `checkout`, `push` · **and git commands that print file contents** — `show`, bare `diff`, anything with `-p` · 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, so `y` waits another two minutes and `n` stops it and keeps what it printed |
| stopped on a budget | any task past `brain.agent_max_steps` (24 model calls); the run reports how many it used, and is told in its last few steps how many are left so it can hand over rather than stop mid-sentence. Not on the final step — a note nothing can act on would only end up stored as the agent's own words |
| refused outright | credential files, however they are reached · force-pushing · `gh auth`, `gh secret` · a command opening with `cd` to a directory that is not there · **a command that only lists** — `ls`, `dir`, `tree` on their own, which `list_files` does for free |

Two of those rows are worth the explanation — and one thing about the first row is worth
saying out loud, because the agent cannot read this file: **the free tools are the ones to
reach for.** Measured on a real run, an agent asked to create a folder spent seven
approvals on `ls -la`, `dir` and `mkdir` before writing anything, when `list_files` is free
and `write_file` creates parent directories itself. Both facts now live in the tools' own
descriptions, which is the only place the model will ever see them.

**A write that cannot happen is refused before you are asked about it.** Every precondition `write_file`, `edit_file` and `delete_file` check is a pure read of the disk, so all of them now run before the gate — the rule `run_command`, `git` and `gh` have had for a while, and which `Tool.unusable` states: *"a prompt that cannot lead anywhere is worse than no prompt: it spends the one thing the gate depends on, which is being worth reading."* Measured on a real run before this: eight identical `edit_file` calls, eight `allow this? [y/N] y`, eight refusals from the tool afterwards, the file unchanged, and twenty of twenty-four steps gone. A third identical failing call is now refused outright rather than run again.

**`read_file` numbers the lines, and `edit_file` does not want the numbers.** The
numbers are there so the agent can say *where* something is; `edit_file` matches on exact
text, so text copied straight out of a read never matches. The failure used to be the whole
of "that text does not appear" — true, a dead end, and an invitation to read the file
again. Measured on a real run: a 298-line file read eleven times in narrowing slices around
two failed edits, three times into the step cap, for one helper function. The error now says
when taking the numbers off would have made it match, and says nothing when it would not —
a diagnosis that fires on every miss is worse than none. When nothing explains it, the
refusal shows the nearest thing that *is* in the file, with its line number, because
what the model sent is recorded nowhere and eight failures left nothing anyone
could diagnose.

**There is a tool that deletes, and `write_file` will not pretend to be one.** Asked to
delete a file, an agent with no delete tool improvised: three failed `edit_file` calls and
then an empty write. Zero bytes is not a deleted file — every `import` of it still resolved
and now exported nothing, which is a worse error than the one it was sent to fix, and the
project was not a git repository. So `delete_file` exists, takes one file and never a
directory, and `write_file` refuses to write an empty string over a file that is not empty.
Four approvals used to turn a fixable problem into an unrecoverable one.

**The agent is told what is in the project before it asks.** It used to be given the
project's path and nothing about its contents, so its first move had to be a discovery
call — and measured, those calls went to the shell: `ls .`, then `ls -la`, then
`dir /s /a`, one model call and one approval each. The briefing now carries the file list
itself, so there is nothing to look around for. Under about 2,500 characters it is every
file in the project; above that it is the top level, labelled as such, and never a
truncated slice of the first — a listing that does not say it is partial is how a model
ends up confidently describing the wrong project. Build caches are left out of it, and out
of `list_files` and `grep` as well: measured on one Next.js app, `.next` was 81 of 126
lines and 69% of everything the agent was shown about the project whose build it had been
asked to fix.

**A hand-off that could not start says so, rather than claiming it ran.** Accepting an
offer used to record "[Handed to the agent.]" *before* the run, so a hand-off that could
not start — a key the provider will not accept — left the conversation asserting a
hand-off that had not happened, with nothing after it. Measured on a real chat: two of
them. Any other failure during a hand-off was worse, because nothing caught it: it ended
the chat. Now the stored turn names what stopped it, nothing is claimed until the run has
been attempted, and the conversation survives either way. A run that *started* and then
failed is unchanged — it already reported itself properly, which is why the free-tier
daily limit was never the problem it looked like.

**A command that only lists is refused, and says what to use instead.** `ls`, `dir` and
`tree` on their own — `list_files` returns the same thing for free, so the obvious spelling
stops costing you an approval. It is narrow on purpose: `ls -la && npm test` is two
commands and you still see the whole line, and `ls -R > tree.txt` writes a file, so neither
is touched. This is a redirect rather than a wall — `cmd /c dir` and a dozen other
spellings reach the same listing and none is caught. What it buys is that the spelling a
model actually reaches for points at the tool instead.

**A command that cannot work does not cost you an approval.** Asked to look at a
project, an agent ran `cd "C:\\Users\\nvs7\\..."` — one character missing from a
path it had retyped itself. The shell stops at a failed `cd`, so nothing after it
runs; but the prompt had already been spent, and the eleven commands it took to
find the right directory spent eleven more. So a leading `cd` to a path that is
not there is refused before you are asked, and the refusal names the project
directory — pointing out the difference when the two are nearly the same, which
is what a mistyped root looks like. `run_command` already starts in the project
directory, so it never needs one.

**The directory it offers is the one your request names.** `mj` asks where the
agent should work and used to suggest wherever it happened to be running. If
what you asked about names a directory, that is suggested instead, so pressing
Enter puts the agent *in* the project rather than above it — and nothing has
to type out an absolute path at all. A bare project name counts: "fix the build
in escalation-timer" and "fix the escalation-timer build" both find it, in the
directory `mj` is running from. A bare name has to name a *project* — something
with a `package.json`, a `pyproject.toml`, a `.git` and so on — so "fix the
build", "run the tests" and "add a test in tests" all leave the default alone
even in a repo that has `build/` and `tests/`, and `node_modules` and `.next`
are never offered. A path you spell out is taken as you wrote it.

**A command that is still working is asked about, not killed — and one approval can
cover a program.** Asked to install and build a Next.js project, an agent spent eight
approvals on two commands. `npm install` outran the two-minute limit, so it tried
`timeout 60 npm install` twice — on cmd.exe `timeout` is a *sleep* with different syntax —
then `--legacy-peer-deps`, then the same `npm run build` four times, twice after being
refused. Three things were wrong and all three are fixed. The limit now asks whether to
keep waiting, because the command is still running while you decide and you know whether
an install is progressing. Answering `a` instead of `y` approves that *program* for the
rest of the task *in the directory you were shown*, so one `npm` approval covers the build
but not an `npm run` somewhere else; a line that chains more than one command is always
shown, however familiar its first word. And a command you have already refused is not put
in front of you a second time. Ctrl+C at the waiting question means "stop waiting" — it
stops the command, not the conversation.

**What a killed command printed is kept.** The drain that closed the pipes after the kill
threw its own output away, so a build that spent two minutes emitting a compiler error
returned that error to nobody — which is most of why that agent kept changing the command
rather than the approach. The output now comes back, labelled partial, keeping the end
rather than the beginning, because that is where a failure says what went wrong.

**Content-printing git commands are gated even though they only read.** `read_file`
refuses `.env` outright — a read means the contents reach a model provider, and a leaked
key cannot be un-leaked — but `git show HEAD:.env` prints the same bytes. Treating git
reads as free would have opened a new ungated path to exactly what the denylist exists to
stop. So the denylist reaches into git's arguments too, and `-p` asks first.

**Force-pushing is refused, but `--force-with-lease` is allowed.** The lease form fails
rather than clobbering when the remote has moved, so refusing it would only push the agent
toward the dangerous flag.

Paths stay confined to the directory you launched from, and the git tool additionally
refuses a repository that sits *above* it, since git otherwise walks upward out of the
project. Both git tools take an argument list rather than a command line, so there is no
shell: no `&&`, no redirection, no substitution.

`--yes` approves every local write without asking, and still refuses to post to GitHub
when stdin is not a terminal. A bad commit is recoverable with git; a comment under your
name on somebody else's pull request is not.

### Knowing things

```
mj brief                  fetch, fuse, print and speak what needs you
  --no-speak              print only
  --explain               show which model handled each source, and why
mj activity               what you have been doing on GitHub
  --refresh               fetch new events first
  --days N                how far back to look
mj remember <fact>        write a memory; omit the fact to list them
  --update NAME           replace an existing one
  --forget NAME           delete one
mj sessions               list live / idle / blocked coding sessions
mj resume <id>            jump back into a session, on the right surface
```

### Wiring it in

Setup offers the two that touch your machine. These are the manual equivalents:

```
mj config                 what is configured, and which model does what
  --list                  every setting you can change, with its default
  --set KEY=VALUE         change one, keeping the rest of the file as it was
  --init                  write an annotated config file to edit
mj mic                    measure your microphone, to tune voice input
mj install-hooks          make Claude Code report session state
mj install-trigger        brief automatically on wake / boot / login
mj tray                   the resident tray icon
```

Each has an `uninstall-` counterpart.

## How it is put together

Two different shapes, and the difference is the most interesting thing here.

**The agent is a loop.** It picks the next action from a tool set and keeps going until it
is done or hits a turn cap. This is the only place a model decides what happens next — and
therefore the only place with a confirmation gate. Reads run freely, writes and commands
are shown and confirmed, paths are confined, credentials are refused outright.

**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. If a source fails it degrades to a plain
list rather than failing.

**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. They were one
module, and every bug at the seam was the two disagreeing about the same conversation —
what was stored differing from what you were shown.

## Development

```
pytest
```

1357 tests. 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
