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

# Kimi Code

> Asymptote support details for Kimi Code (Moonshot AI) endpoint telemetry

## Runtime overview

Asymptote supports Kimi Code, Moonshot AI's coding agent, through Kimi Code's
native lifecycle hooks sent to `beacon-hooks`.

```bash theme={null}
beacon endpoint hooks install --harness kimi
```

`--harness kimi-code` and `--harness kimi-code-cli` are aliases for the same
integration. The CLI, desktop app, VS Code extension, and ACP server all use the
same agent core and normalize to the `kimi_code` harness.

<Note>
  Kimi Code has no OpenTelemetry export. `KIMI_DISABLE_TELEMETRY` controls
  Moonshot's own product telemetry, not Asymptote collection. Native hooks are the
  entire integration surface.
</Note>

## Prerequisites

* Install `kimi`. It does not need to have been run before hook installation.
* Run `beacon endpoint install` so endpoint configuration and runtime log paths
  exist.
* Start a new Kimi Code session, or run `/reload`, after installing or removing
  hooks. Kimi Code reads `config.toml` at startup.

## Collection path

Asymptote appends managed entries to the `[[hooks]]` array in
`$KIMI_CODE_HOME/config.toml`. `KIMI_CODE_HOME` defaults to `~/.kimi-code`.

<Warning>
  `config.toml` can contain provider API keys in plain text. Asymptote appends its
  hook entries without re-serializing the rest of the file, then parses and
  compares the result before replacing the original. Existing settings, secrets,
  comments, and non-Asymptote hooks are preserved byte for byte.
</Warning>

Asymptote refuses to modify:

* a `config.toml` that does not parse;
* a config that declares `hooks` as an inline array (`hooks = [{ ... }]`),
  because TOML does not permit appending `[[hooks]]` entries after it.

`beacon endpoint discover` reports the inline-array case as `misconfigured`.

<Warning>
  Kimi Code has no project-scoped hook configuration. `--level project` is
  refused instead of silently changing the user-wide config. To isolate telemetry
  for one project, set `KIMI_CODE_HOME` to a project-specific data root first.
</Warning>

## Registered events

Asymptote subscribes to these Kimi Code hooks:

| Event | Coverage |
| - | - |
| `SessionStart`, `SessionEnd` | Session lifecycle |
| `UserPromptSubmit` | Submitted prompts |
| `PreToolUse`, `PostToolUse`, `PostToolUseFailure` | Tool lifecycle and failures |
| `PermissionRequest`, `PermissionResult` | Observed operator approval decisions |
| `Stop` | Turn completion |
| `SubagentStart`, `SubagentStop` | Subagent lifecycle |
| `PreCompact`, `PostCompact` | Context compaction |

Beacon deliberately does not register `SessionHeartbeat`, `UserPromptQueued`,
`TurnStarted`, `TaskStarted`, `Notification`, `StopFailure`, or `Interrupt`.
Those events would duplicate another event, create a heartbeat process merely
by subscribing, or assert a lifecycle state the endpoint schema cannot express
accurately.

## Discovery and status

```bash title="Show Kimi Code hook status" theme={null}
beacon endpoint hooks status --harness kimi
beacon endpoint discover
beacon endpoint inventory
```

Kimi Code reports as `kimi_code` with capability `hooks`, and emitted events use
`harness.collection_method=hook`. Inventory reports `config.toml` as native
configuration and marks it `beacon_managed` only when an Asymptote hook command
is present.

## Install or configuration support

```bash theme={null}
beacon endpoint hooks install --harness kimi
beacon endpoint hooks status --harness kimi
beacon endpoint hooks uninstall --harness kimi
```

Reinstall replaces Asymptote's entries rather than adding duplicates. Uninstall
removes only Asymptote entries and leaves the rest of the file unchanged.

## Telemetry coverage

| Area | Support |
| - | - |
| Runtime discovery | `$KIMI_CODE_HOME/config.toml` |
| Harness attribution | Kimi CLI, Code, and ACP spellings normalize to `kimi_code` |
| Hook management | Install, status, uninstall, and repair at user scope |
| Session lifecycle and prompts | Supported |
| Tool use and failures | Supported, including tool call IDs |
| Commands | Command, output, and non-zero exit code where exposed |
| File activity | Reads and modifications with paths, operations, and diffs |
| MCP activity | `mcp__<server>__<tool>` names are split into server and tool |
| Subagents and compaction | Supported |
| Approval decisions | Observed from `PermissionRequest` and `PermissionResult` |
| Token usage and cost | Not exposed by Kimi Code hooks |
| Assistant message text | Not exposed by Kimi Code hooks |
| Local JSONL and dashboard | Supported |

Kimi's `Read`, `ReadMediaFile`, `Glob`, and `Grep` tools map to file reads.
`Write` and `Edit` map to file modifications, while `Bash` maps to command
execution. Failed writes remain `tool.failed` and do not generate a file diff
for a change that never landed.

## Approvals and enforcement

Kimi Code exposes real operator decisions. `approved` maps to
`approval.allowed`; `rejected`, `cancelled`, and `error` map to
`approval.denied`, with `approval.decision` preserving the exact outcome.
Arguments from the decided call are retained, so command and file approval
rules can evaluate the actual operation.

Optional enforcement remains behind `BEACON_POLICY_PROVIDER` and fails open on
provider errors. Kimi only honors blocking responses for `PreToolUse`, `Stop`,
and `UserPromptSubmit`; a response to `PermissionRequest` is observation-only.

## Known gaps

* No token usage or cost. Kimi's compaction token count is not per-call usage.
* No assistant response text in hook payloads.
* No interruption event in the endpoint schema.
* No project-level hook configuration.
* Hooks are fail-open if a command times out, crashes, or exits unexpectedly.

## Troubleshooting

```bash theme={null}
beacon endpoint hooks status --harness kimi
beacon endpoint doctor
grep '"name":"kimi_code"' ~/.beacon/endpoint/logs/runtime.jsonl | tail -3
```

If events are missing, check `KIMI_CODE_HOME`, confirm the hook commands contain
`--platform kimi`, start a new session or run `/reload`, and inspect
`$KIMI_CODE_HOME/logs/` for hook startup errors.

## Related

<Columns cols={2}>
  <Card title="Supported agent harnesses" icon="list-check" href="/runtimes">
    Return to the runtime support overview.
  </Card>

  <Card title="Agent harness integration model" icon="plug" href="/runtimes/integration-model">
    See how Asymptote discovers and configures each runtime.
  </Card>
</Columns>
