# omp

> Set up the Comity extension and MCP server for omp (oh-my-pi).

omp has no command-hook config file, so Comity integrates through an omp extension: a TypeScript module that omp loads in-process. Because it is executable code, `comity init` only installs it when you choose omp explicitly.

## Set up

```sh
cd your-repo
comity init --tools omp
git add .omp/extensions/comity/index.ts .omp/mcp.json
git commit -m "Set up Comity for omp"
```

Start omp from the repository root: omp loads `.omp/extensions` from its working directory.

## What init writes

### `.omp/extensions/comity/index.ts`

The bridge extension (first line `// comity-omp-bridge v1 (comity hook)`). It:

- forwards omp events to Comity: `session_start`, `before_agent_start` (each prompt), `tool_call` and `tool_result` for the tools `bash`, `edit`, `apply_patch`, `write`, `eval` and `ast_edit`, `session_stop`, and `session_shutdown`;
- evaluates in-process through the installed CLI's `hook-lib.mjs` (no Node process per tool call), falling back to spawning `comity hook --tool omp`;
- waits at most 600 ms per event and then allows, because omp blocks a tool whose handler throws or hangs. Context that arrives late is delivered with the next reply;
- reports subagents with their parent session, so a parent and its subagents are treated as one lineage and never conflict with each other.

Reads, searches and omp internal URIs (`local://`, `artifact://`, …) never leave the process. The file holds no token and no machine-specific path. Re-running `comity init --tools omp` rewrites it; `comity doctor` warns when it is from another CLI version.

The bridge finds the CLI next to `comity` on your `PATH`. If yours is installed elsewhere, set `COMITY_CLI_DIR` to the folder containing `comity.mjs`.

### `.omp/mcp.json`

```json
{
  "mcpServers": {
    "comity": {
      "type": "http",
      "url": "https://api.comity.so/mcp",
      "headers": { "Authorization": "!comity auth-header" }
    }
  }
}
```

omp runs a header value that starts with `!` as a command and sends its output; `comity auth-header` prints `Bearer cmt_…` from `COMITY_TOKEN` or your login.

## What your agent sees

- **First prompt of a session**: the session-start briefing together with the prompt's context.
- **Before a tool call**: a block denies it with Comity's reason; warnings are added as context.
- **After a tool call**: new conflicts, messages, answers and arrival notices.

## Verify

```sh
comity doctor
```

Expect `omp extension  bridge installed at …` and `omp mcp  configured in …/.omp/mcp.json`. The omp checks only appear once the bridge or the MCP entry exists.
