> For AI agents: the complete documentation index is available at https://renmori.mewbaka.cn/en/llms.txt, the full documentation bundle is available at https://renmori.mewbaka.cn/en/llms-full.txt.

# Output, Build Manifest and Exit Codes

`renmori` serves both developers and automated pipelines: developers read the styled, localized progress output on stderr, while scripts and CI parse the result JSON on stdout and the exit code. The two are independent, and the output language and color settings do not affect the content of stdout.

## Output channels

| Channel | Content                                                                                                                        | Affected by `--lang`, `--no-color` | Affected by `--quiet`                                            |
| ------- | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------- | ---------------------------------------------------------------- |
| stderr  | Banner, configuration notices, summary panel, confirmation prompts, step lines, result panel, release guidance, error messages | Yes                                | Yes; only error messages in the form `error: <message>` are kept |
| stdout  | The last line is always a JSON object                                                                                          | No                                 | No                                                               |

JSON keys and values are always in English and have the same structure under any locale. Parsers should read the last line of stdout.

## Result JSON of `protect`

Protection succeeded:

```json
{
  "status": "ok",
  "output": "/abs/path/MyGame-1.0-pc-protected",
  "manifest": {
    "file_count": 842,
    "container_sha256": "9f2c…",
    "strength": "baseline"
  },
  "backup": "/abs/path/MyGame-1.0-pc_bak"
}
```

The actual output is single-line JSON; it is formatted here for readability.

| Field                       | Description                                                                                 |
| --------------------------- | ------------------------------------------------------------------------------------------- |
| `status`                    | `"ok"`                                                                                      |
| `output`                    | Absolute path of the protected build                                                        |
| `manifest.file_count`       | Number of files sealed into the container                                                   |
| `manifest.container_sha256` | SHA-256 of the container file                                                               |
| `manifest.strength`         | The protection strength actually used                                                       |
| `backup`                    | The backup directory created by in-place protection; present only when a backup was created |

Failure:

```json
{"status": "error", "message": "/abs/path/MyGame has no 'game/' directory"}
```

Cancelled at the confirmation prompt:

```json
{"status": "aborted"}
```

## Result JSON of `verify`

| Result                 | JSON                                                              |
| ---------------------- | ----------------------------------------------------------------- |
| Passed                 | `{"status": "ok", "file_count": 842, "container_sha256": "…"}`    |
| Check failed           | `{"status": "error", "problems": ["container sha mismatch", …]}`  |
| Build manifest missing | `{"status": "error", "message": "no renmori-manifest.json in …"}` |

## Build manifest renmori-manifest.json

`protect` writes `renmori-manifest.json` to the root of the protected build, recording the result of this protection run for use by `verify` and the release workflow. The file lies outside `game/` and contains no keys.

### Baseline protection

```json
{
  "renmori_version": "1.0.0",
  "container_format": 1,
  "strength": "baseline",
  "chunk_size": 65536,
  "lockdown": true,
  "container_sha256": "9f2c…",
  "container_bytes": 1073741824,
  "file_count": 842,
  "files": [
    {"name": "audio/theme.ogg", "size": 4194304},
    {"name": "images/bg room.png", "size": 812345}
  ]
}
```

| Field              | Description                                                                                                                                               |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `renmori_version`  | Version of `renmori` that performed the protection                                                                                                        |
| `container_format` | Container format version, `1` for baseline; for the format definition see [Container format](https://renmori.mewbaka.cn/en/technical/container-format.md) |
| `strength`         | Protection strength                                                                                                                                       |
| `chunk_size`       | Chunk size in bytes                                                                                                                                       |
| `lockdown`         | Whether lockdown is enabled                                                                                                                               |
| `container_sha256` | SHA-256 of the container file, which `verify` uses to detect changes                                                                                      |
| `container_bytes`  | Size of the container file in bytes                                                                                                                       |
| `file_count`       | Number of files sealed into the container                                                                                                                 |
| `files`            | List of files sorted by name; each entry contains the game-relative path `name` and the original size `size`                                              |

### Full protection

```json
{
  "renmori_version": "1.0.0",
  "container_format": "poly",
  "strength": "poly",
  "lockdown": true,
  "container": "renmori.rmc",
  "container_sha256": "9f2c…",
  "file_count": 842,
  "script_count": 120,
  "platforms": ["win-x64", "linux-x64"],
  "cores": [],
  "launcher": null
}
```

| Field              | Description                                                                   |
| ------------------ | ----------------------------------------------------------------------------- |
| `container_format` | `"poly"`, indicating the per-build polymorphic format generated by the plugin |
| `strength`         | Protection strength reported by the plugin                                    |
| `container`        | Container file name reported by the plugin                                    |
| `script_count`     | Number of transformed scripts                                                 |
| `platforms`        | Target platforms generated by the plugin                                      |
| `cores`            | Native cores written into the build by the plugin                             |
| `launcher`         | Native launcher information; empty when not enabled                           |

The full protection manifest does not include a per-file list. The concrete values of `platforms`, `cores` and `launcher` are determined by the plugin; the example above illustrates only the structure.

:::warning
The build manifest remains in the build directory. The `files` field of the baseline manifest lists the paths and sizes of all assets, but contains no content or keys. If you do not want the release to include this file, move it out after `verify` completes and before uploading; verifying again later requires this file.
:::

## Exit codes

| Exit code | Name                        | Triggered by                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| --------: | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|         0 | Success                     | Protection completed; all verification checks passed                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|         2 | Usage or precondition error | Input directory lacks `game/`; build already protected; `-o` directory or `_bak` backup already exists; configuration file does not exist, or TOML parsing support is missing; key environment variable has an invalid format; plugin required for full protection unavailable; specified strength not supported by the plugin; no files to pack; `.zip` contains no build or more than one build, contains an unsafe path, or is corrupted; cancelled at the confirmation prompt; `verify` cannot find the build manifest; invalid command-line arguments (reported by the argument parser, in which case no JSON is printed) |
|         1 | Runtime failure             | Error during packing, for example an unsupported RPA format; plugin execution failed; `verify` found problems                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

Pipelines can use this to distinguish "the input or configuration needs correcting" (2) from "the build itself has a problem" (1). For how to resolve each error message, see [Troubleshooting](https://renmori.mewbaka.cn/en/cli/troubleshooting.md).

## Parsing in scripts

Read the result with `jq`:

```bash
renmori protect ./build/MyGame-pc --no-backup --quiet -y | tail -n 1 > result.json
jq -r '.manifest.container_sha256' result.json
```

Read it in Python:

```python
import json
import subprocess

proc = subprocess.run(
    ["renmori", "verify", "./out", "--quiet"],
    stdout=subprocess.PIPE, text=True,
)
result = json.loads(proc.stdout.strip().splitlines()[-1])
if proc.returncode != 0:
    raise SystemExit(result.get("problems") or result.get("message"))
```
