> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monolex.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# NIIA

> NIIA self-drive modes, continuous memory, code intelligence, terminal orchestration, MCP, remote machines, and controlled OS access.

NIIA (Neural Intelligence Integration Architecture) is the entry point to the Mono tool stack. It gives humans and AI agents one CLI for recalling prior work, searching code and documents, driving terminal sessions, bridging MCP services, reaching other machines, and entering the operating-system control gate.

*Published contract: `NIIA 0.9.50` (`niia` CLI), OpenCLIs build
`2026-07-20-161619`. The executing binary, installed receipt, and public CDN
metadata agree on this release; the registry owns discovery copy and links.*

<Card title="Meet NIIA before the reference" icon="brain" href="https://monolex.ai/tools/niia/">
  See how one memory continues across AI CLIs; use these docs for the current command and security contract.
</Card>

## Start here

```bash theme={null}
niia recall                         # recover the current work context
niia mode                           # see who drives the work-entry discipline
niia mode preset default           # choose a routing preset
niia gauge "update the login flow"  # classify non-trivial work and record its promise
niia search "session gateway"       # search docs, code, and git
niia code context "login flow"      # ask Monogram for bounded code context
niia session list -n 5              # find recent AI CLI sessions
niia doctor                         # check estate freshness and recovery actions
niia resonate                       # diagnose knowledge and infrastructure state
```

Run bare `niia` for the guide embedded in your installed binary. Use `niia --version` to identify the release that owns that guide.

## One entry point, several owners

```text theme={null}
AI CLI sessions ── memory ───────────────┐
                                          │
documents ──────── Monomento ────────────┤
code ───────────── Monogram ─────────────┤
git ────────────── Monogit ──────────────┤
knowledge flow ─── Monoflow + Work Wiki ─┤
                                          ▼
                                        NIIA
                                          │
                 ┌────────────────────────┼──────────────────────┐
                 ▼                        ▼                      ▼
          terminal sessions          MCP services        OS + remote machines
```

NIIA composes these systems; it does not erase their ownership boundaries.

| NIIA surface                                           | Owner behind the surface                     | What the boundary means                                                                                                    |
| ------------------------------------------------------ | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `niia docs ...`                                        | Monomento                                    | Document search, reading, reference graphs, and statistics                                                                 |
| `niia code ...`                                        | [Monogram](/ai-clis/monogram/overview)       | Code search, context, call graphs, dependencies, and symbols                                                               |
| `niia monograph ...`                                   | [Monograph](/ai-clis/monograph)              | Reads reusable Book knowledge; task routing and source proof remain Monogram/agent responsibilities                        |
| `niia git ...`                                         | Monogit                                      | Branch, commit, and diff structure                                                                                         |
| `niia search`, `insights`, `gaps`, `drift`, `chain`    | [Monoflow](/ai-clis/monoflow)                | Composes code, git, documents, watcher events, and saved diffs; focused findings still need proof from their owning source |
| `niia convergence`                                     | [Work Wiki](/ai-clis/work-wiki)              | Compares Monoflow code topics with per-project research, prepare, prove, and final-doc coverage                            |
| `niia reindex`                                         | Mono stack                                   | Refreshes the participating indexes in dependency order                                                                    |
| `niia mode`                                            | NIIA self-drive switch                       | Chooses automatic hook steering or manual invocation and deploys a named routing preset                                    |
| `niia gauge`, `finish`, `audit-entry`, `doctor`        | NIIA work-entry discipline                   | Records and re-presents a proportional session promise, audits it without gating, and reports fast estate recovery actions |
| `niia setup`, `setup use ...`                          | NIIA install boundary                        | Reconciles bundled skills and the PATH-facing binary while preserving an explicit Monolex/OpenCLIs source choice           |
| `niia observe ...` / `niia control ...`                | [Kernel CLI](/kernel-cli) behind NIIA's gate | NIIA owns authorization; Kernel CLI performs the OS operation                                                              |
| `niia serve`, `daemon`, `devices`, `remote`, `mailbox` | [Monosystem](/ai-clis/monosystem) transport  | NIIA forwards the command without pretending to own gateway runtime state                                                  |
| `niia mcp`                                             | NIIA CLI-to-MCP bridge                       | Exposes the non-recursive NIIA command surface as typed MCP tools                                                          |

## Capability map

### Remember and search

```bash theme={null}
niia recall
niia session read latest --tool codex
niia session search "what we decided"
niia docs search "SessionActor" --read
niia search "SessionActor" --resonate
```

Session readers understand Claude, Codex, Grok, OpenCode, Gemini, and agy/Antigravity formats when those tools have local data available. Search indexing is explicit with `niia index --sessions`.

### Investigate code and knowledge

```bash theme={null}
niia code search "create session"
niia code context "where login state enters the app"
niia code chain create_session --callers --depth 2
niia insights
niia gaps
niia convergence
```

`niia code` is the integrated façade. Use the standalone [Monogram reference](/ai-clis/monogram/reference) when you need region ranking, coupling audits, format planes, deep semantic analysis, or possibility-band worklists.

Use the standalone [Monoflow command reference](/ai-clis/monoflow) for temporal and cross-database drills or its typed 24-command MCP surface. Use [Work Wiki](/ai-clis/work-wiki) for the full session, intent, artifact, knowledge-DB, file-biography, and convergence command set.

### Carry the work-entry promise

```text theme={null}
                         routing preset
                    default · strict · quiet
                              │
                              ▼
prompt ── AUTO mode ── hooks ── gauge ── witness ── finish ── audit
   │
   └──── MANUAL mode ──────────── you call the same verbs yourself
```

`auto` means the machine carries the entry ceremony through three hooks.
`manual` removes only NIIA's hooks; it does not disable NIIA or its verbs.
Presets tune what is announced while preserving the witness and report-only
audit boundary:

| Preset    | Behavior                                                          |
| --------- | ----------------------------------------------------------------- |
| `default` | Balanced routing and normal rung announcements                    |
| `strict`  | Every prompt announces its rung; no silent lane                   |
| `quiet`   | Witness and audit stay active while prompt injection is minimized |

```bash theme={null}
niia mode auto                    # let hooks steer this project
niia mode manual                  # call gauge/finish/audit yourself
niia mode preset                 # list presets and the active choice
niia mode preset quiet           # deploy a preset; custom routing is backed up
niia mode routing                # inspect the active routing table
```

```bash theme={null}
niia gauge --rung MODERATE "change the existing session gateway"
niia gauge --transcript ./bench-transcript.jsonl "audit an ad-hoc run"
# Follow its [NEXT] chain. If the scope changes:
niia gauge --re "the change now crosses the public wire contract"

# Close only after the final product mutation:
niia finish
niia audit-entry
```

`gauge` classifies `TRIVIAL`, `MODERATE`, `HIGH`, or `CLAIM` work and also
recognizes silent lookup, documentation, conversation, and continuation lanes.
An explicit user rung always wins. Risk language still produces `[CONSENT]`,
and fan-out remains a proposal. In 0.9.50, ASCII signal words use word
boundaries, so `add` no longer fires inside `address`; Korean stems remain
substring-matched. Put all options before the trailing `TASK` text; tokens
after the task are not parsed as flags. `--transcript <path>` supplies an
ad-hoc or benchmark transcript when no hook event supplied one, allowing the
later audit to inspect that witness.

The command writes `gauge.json` under the repository's
`.niia/session-order/` directory, or under a cwd-hashed home path outside Git.
History is append-only, and a side-lane prompt preserves the active work rung
and `[NEXT]` chain. Only a session id carried by hook stdin may atomically move
the `current` pointer. A CLI `--session <id>` run writes that session's witness
without stealing the live pointer, while ad-hoc and static probes remain
isolated. `finish` re-presents the promise, current Monogram sequence phase,
and HIGH-work ledger reminder before writing `finish.json`. `audit-entry`
writes `audit-report.json` and never blocks; escalation is an event, not a
violation. Claude JSONL is readable today, while Codex transcript auditing is
explicitly `SUSPENDED` until its reader ships.

For a completed run whose transcript arrives only at the end, pass
`audit-entry --transcript <path>` to perform a post-hoc audit. For a baseline
arm that never ran `gauge`, use `--no-witness --transcript <path>` with an
explicit assumed rung. Contract-only checks are skipped instead of being
manufactured as failures; `--wide-evidence` must be applied to both comparison
arms.

NIIA 0.9.50 also serves 14 embedded flow topics directly through bare
`niia docs`: agent flow, self-drive, terminal drive, OS control, remote estate,
memory, MCP, code/git/docs, consciousness, operations, changelog, watcher,
install/trust, and the topic index. The indexed document-data commands remain
available as `niia docs search|tree|list|peek|read|deps|rdeps|bridge|stats`.

Hook modes never fail the calling prompt because of an internal NIIA error:
they keep exit zero, write stderr plus `~/.niia/hook-error.log`, and let
`doctor` expose the recent failure. `doctor` is the separate sub-second health
view. It checks WAL-aware database mtimes, prefers the watcher's own dirty-pass
verdict when available, detects repeated launchd deferral, verifies all three
UserPromptSubmit/SessionStart/SessionEnd hook lanes, and checks witness
writability. Stale or failing rows carry a concrete `[NEXT]` recovery verb.
The [complete command map](/niia-cli/commands#work-entry-self-drive) documents
every option, rung, threshold, and audit class.

### Close non-trivial code work as one loop

```bash theme={null}
monogram sequence start task --from <task.md>
# Read connection-points.md, then read every exact routed Book candidate:
niia monograph read <ENTRY-ID> --book fix-shape-patterns

# Only when no exact ID was routed, let Monograph choose the best Book:
niia monograph open "<symptom>"

# Implement and test every bound edge; after the final file mutation:
monogram sequence finish current
```

Monogram supplies **where** the task touches code and preserves the required
order. Monograph supplies reusable mechanism knowledge. The agent still proves
**whether** a candidate applies. `sequence start` auto-runs `define`; there is
no separate `sequence bind` step. Exact routed entry IDs take priority. Use
`monograph open` only when no exact candidate was routed; that command chooses
the best Book for the symptom. Run `finish` only after the final Edit/Write,
read its closing review, and make no later source mutation.

### Drive terminal sessions

```bash theme={null}
niia health
niia ask --session <ID> "run the focused tests"
niia follow-up --session <ID> "now check the failure" --expect-last "tests"
niia expect-screen --session <ID> "finished" --max-wait 120
niia step --session <ID> --send "cargo check" --expect "Finished"
```

The health gate distinguishes a live, drivable PTY from a stale screen. Assertions time out with a non-zero exit instead of silently treating missing output as success.

### Bridge MCP in both directions

```bash theme={null}
# MCP service → CLI
niia mcp-run chrome-devtools _help
niia mcp-run chrome-devtools navigate_page url=https://monolex.ai

# CLI → MCP
niia mcp                         # serve NIIA itself
niia mcp-serve monogram          # serve Monogram's typed schema
```

Local stdio services accept scalar `key=value` and structured `key:=JSON` arguments. Remote REST accepts scalar query arguments only. MCP, JSON-RPC, session, quota, authentication, and REST failures return a non-zero shell exit; `--json` keeps an MCP `isError` payload on stdout before that exit.

### Observe and control the operating system

```bash theme={null}
niia observe permissions --json
niia observe targets --app Safari --json

niia control unlock --scope full --duration 30m
niia control act "Open" --app Safari --dry-run --json
niia control lock all
```

Safe metadata reads remain available without a control grant. Screen content and write operations cross an explicit unlock boundary. NIIA keeps the authorization token; the [Kernel CLI command surface](/kernel-cli/commands) performs the observation or action.

For web-page DOM, JavaScript, network, and logged-in browser workflows, use [MonoSurf](/monosurf/index). When a browser flow opens a native file picker or system dialog, hand that step to Kernel CLI and then return to MonoSurf for page verification.

### Reach another machine

```bash theme={null}
niia remote status list
niia remote exec <machine> now
niia remote sessions <machine>
niia remote ask <machine> "hostname"
niia daemon gate status --json
niia remote update <machine> niia --dry-run
```

`remote exec` is a diagnostic surface restricted to exact `now`, `status`, and `--version` requests. Terminal work uses the relay surface after reachability is proven. File transfer uses an exact Headless session rather than widening the diagnostic command allowlist.

Version 0.9.50 forwards Monosystem's scoped remote-update contract. A dry-run
returns `openclis.update-plan.v1` without installing or requiring the target's
mutation gate. Applying an exact named scope or `--all` requires the target
device's `upgrade` gate; `openclis` and `openclis-vault` remain local-only
because their keychain approval is interactive. Legacy `remote upgrade` means
NIIA only, never all tools.

## Live public contract

The `0.9.50` release has one command contract across its four published
platform fragments:

| Surface                | Count | Why the number differs                                                                                                                 |
| ---------------------- | ----: | -------------------------------------------------------------------------------------------------------------------------------------- |
| Top-level CLI commands |    63 | Includes `mode`, work-entry discipline, setup, login/logout, MCP management, automation, and transport; generated `help` is additional |
| Generated MCP schema   |   109 | Flattens supported nested commands and excludes blocking or recursive server-management operations                                     |
| Live `niia mcp`        |   110 | The generated schema plus the live server's self-status surface                                                                        |

These counts describe different contracts. A source manifest, an installed binary, and a running MCP server are not interchangeable proof.

### Release provenance and platform matrix

The public 0.9.50 build is `2026-07-20-161619`. Its `latest.json` pointer and
all four immutable platform fragments record source commit
`46dd0451b5c8e6cf0aaff3a3c0ca9fdbb14ac766` with `source_dirty: false`.
The installed macOS binary reports `git 46dd0451b`, matching that release
commit prefix.

| Platform key      | Archive SHA-256                                                    | Verified boundary                                                                                                            |
| ----------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `darwin-aarch64`  | `183176340d7af5263131c957650b24c6b1c25ce38337c801d622efd5e20cf752` | OpenCLIs-installed payload executed; strict signature, 109-command schema, 110-tool server, and packaged guide pair verified |
| `linux-x86_64`    | `9cc0222c79bc0aa2acdeecb968e220bcc0099d813013300bdf72158304dfd43a` | Clean x86-64 Linux release fragment                                                                                          |
| `windows-x86_64`  | `a4029edebbdf55b96fd5ec43e89989e3761bbabaec77851acd4ca4c1641b4761` | Clean Windows x86-64 fragment; PE payload and normalized guide pair verified                                                 |
| `windows-aarch64` | `05c3010ac5b3efc161af7287bf9b05b24837e5cdb5322dd4bf1e0a00531e656f` | Clean Windows ARM64 release fragment                                                                                         |

No Intel macOS or Linux ARM64 archive is present in the 0.9.50 metadata. Every
published fragment carries the same `initiate.md`/`SKILL.md` guide pair.

## Install and update

```bash theme={null}
curl -fsSL https://openclis.com/install.sh | sh
openclis install niia
openclis update niia
niia setup use openclis              # select the OpenCLIs binary explicitly
niia --version
```

In 0.9.50, `setup use openclis` makes `~/.niia/bin/niia` a symlink to
`~/.openclis/bin/niia` on Unix, so later OpenCLIs updates flow through that
link. `setup use monolex` replaces it with a regular copy. Windows cannot use
that Unix selector: `setup use openclis` copies the current OpenCLIs executable
to `$HOME\.niia\bin\niia.exe`, and a regular copy is reported as `monolex` by
the current status detector. Run the newly installed executable explicitly
after each Windows update when the PATH-facing copy must be refreshed:

```powershell theme={null}
& "$HOME\.openclis\bin\niia.exe" setup use openclis
Get-Command niia
niia --version
```

The 0.9.50 selector does not write a `.niia-source` ownership marker. Treat the
Unix symlink target or the Windows copied payload itself as the evidence, and
verify the active result with `Get-Command niia` plus `niia --version`.

## Continue

<CardGroup cols={2}>
  <Card title="NIIA overview" href="/niia-cli/overview">
    Identity, memory, and the integration model.
  </Card>

  <Card title="Complete command map" href="/niia-cli/commands">
    All top-level families, nested commands, gates, and ownership boundaries.
  </Card>

  <Card title="AI sessions" href="/niia-cli/sessions">
    Read, search, and safely drive sessions across AI CLIs.
  </Card>

  <Card title="Security model" href="/niia-cli/security">
    Authentication, MCP failure behavior, OS unlocks, and remote restrictions.
  </Card>

  <Card title="Claude account profiles" href="/ai-clis/monoswitch">
    Save, switch, and isolate Claude Code accounts without making NIIA the credential owner.
  </Card>
</CardGroup>
