Retrieved article excerpt
Open article · Retrieved 2026-11-04T13:23:37.902112+00:00
# `@shield-agent/kya`
[npm](https://www.npmjs.com/package/@shield-agent/kya)
[npm downloads/week](https://www.npmjs.com/package/@shield-agent/kya)
[npm downloads, 18 months](https://www.npmjs.com/package/@shield-agent/kya)
[License: MIT](https://github.com/The-Pixel-Boys/shield-kya/blob/main/LICENSE)
[Install](https://shield-agent.com/install)
[X](https://x.com/coscosmico)
**Audit trail and traceability for AI agents.** See what every coding agent did and check each tool call against policy. Every tool call is recorded on a live local dashboard and can be checked against the Agent Trust Baseline. The open source client is advisory and fails open (an error lets the call through), apart from a small never-list of dangerous calls that is always denied. Real blocking and human approval run on the MCP policy path against a hosted workspace (the Shield Agent cloud service). One command. Free forever under MIT.
```
npm i -g @shield-agent/kya@latest && kya start
```
Requires **Node.js 22+** (24 recommended). Restart Cursor / Claude Code / Codex once so MCP loads. Hosted desk: [shield-agent.com](https://shield-agent.com/install).
CLI and local MCP gate for Shield’s Know Your Agent path.
An agent that asks Shield first gets Allow, Review, or Deny: you register the agent, wrap the tool (or route it through the MCP gate or the hosted plane), and Review waits for a person. Local hooks only record and block the never-list (see [Hook interception](https://github.com/The-Pixel-Boys/shield-kya#hook-interception)). Hosted is where enforcement lives. This package does not scan your network. Agents that never call evaluate stay invisible on purpose.
Walkthrough: [how you use it](https://shield-agent.com/how-kya-works#using).
```
npx @shield-agent/kya@latest --help
npx @shield-agent/kya@latest --version
```
`--version`, `-v`, `-V` and `kya version` print the installed package version on one line and exit `0`. They read the local package only: no network, no banner, no config.
Requires **Node.js 22+** (`engines.node: >=22`); 24 is the recommended line. Node 20 and 21 are unsupported but work: the CLI prints a one-line warning. Node 18 and older are unsupported and some features break there (HTTP `serve-mcp`, the gateway OTLP receiver). Below 22 the CLI offers to install Node 24 for you (via volta / fnm / nvm / brew), reinstall itself, and finish the command. If you decline, it just prints the warning and continues. `kya hook` never warns or prompts.
It works with any host that speaks MCP or OpenAPI. Vertical packs are optional. Shield is the only policy decision point (the one place that decides Allow or Deny). This gate never auto-approves an irreversible side effect (a change you cannot undo).
If `KYA_API_KEY` is empty against an authenticated plane, network commands exit non-zero. `eval-tool`, `wrap`, and `invoke` exit `0` on ALLOW, `4` on REQUIRE\_APPROVE, and `1` on DENY or unknown, so a line like `eval-tool && write` cannot skip the gate. `wrap` runs in observe mode by default, so it exits `0` on REQUIRE\_APPROVE too. Set `KYA_HOLD=1` or pass `--hold` to get the `4`.
`--offline` runs sample evaluate without a paid cloud (useful for DENY and REQUIRE\_APPROVE demos). Creating an agent is itself a tool: offline, `kya.agent.register` comes back REQUIRE\_APPROVE. Allow, break-glass, and approve mint modes (the modes that create approvals) live on the control plane.
## One liner
```
npm i -g @shield-agent/kya@latest && kya start
```
Run it in your project directory. (From a clone of this repo, `./scripts/install-local.sh` replaces the npm install.)
More ways to install (same package; npm stays the reference path):
```
# Homebrew. Homebrew 7 may ask you to trust a third-party tap: run `brew tap The-Pixel-Boys/tap` first.
# The formula does not install the semantic-search runtime. Search stays lexical until you opt in (see Natural-language search).
brew install The-Pixel-Boys/tap/shield-kya
# Scoop (not yet verified on Windows)
scoop bucket add The-Pixel-Boys https://github.com/The-Pixel-Boys/scoop-bucket.git
scoop install shield-kya
```
Claude Code users can also install the [plugin](https://github.com/The-Pixel-Boys/shield-kya#claude-code-plugin); GitHub Copilot CLI users the [Copilot CLI plugin](https://github.com/The-Pixel-Boys/shield-kya#github-copilot-cli-plugin) (read its first paragraph before installing); Codex CLI users the [Codex plugin](https://github.com/The-Pixel-Boys/shield-kya#codex-plugin); Gemini CLI users the [Gemini CLI extension](https://github.com/The-Pixel-Boys/shield-kya#gemini-cli-extension). Cline users: `npm install -g @shield-agent/kya@latest`, then follow [`llms-install.md`](https://github.com/The-Pixel-Boys/shield-kya/blob/main/llms-install.md). It is written so Cline can follow it; a Cline run from that file alone has not been tested yet.
That **inits** `.kya/`, **wires** local MCP (`.mcp.json`, `mcp.json`, `.cursor/mcp.json` → `kya serve-mcp --stdio`), also **wires user-level configs for every installed host it detects** (`~/.claude.json`, `~/.kimi-code/`, `~/.grok/`, `~/.cursor/`, …), and **opens** the live activity report. The report runs in the background, so you get your terminal back. `kya stop` stops it. `kya receipt --open` reopens it. Cursor, Kiro, Qwen, Amp, Droid, Cline, and Grok pick the server up live with no restart (Kimi: just a new session). Claude Code, Codex, OpenCode, Gemini, Copilot CLI, and Kilo CLI load it on next launch. `claude --resume` keeps your conversation.
[KYA report live dashboard: Certify trust baseline, decisions, analytics](https://raw.githubusercontent.com/The-Pixel-Boys/shield-kya/main/assets/report-overview.png)
[Certify tab: full Agent Trust Baseline requirement table with evidence](https://raw.githubusercontent.com/The-Pixel-Boys/shield-kya/main/assets/report-certify.png)
[Activity tab: filterable agent tool-call feed with decisions](https://raw.githubusercontent.com/The-Pixel-Boys/shield-kya/main/assets/report-activity.png)
[Changes tab: what actually changed per session, files touched with redacted diff previews](https://raw.githubusercontent.com/The-Pixel-Boys/shield-kya/main/assets/report-changes.png)
[Gateway section: local MCP gate with listeners, routes, backends, policies, and a dry-run playground](https://raw.githubusercontent.com/The-Pixel-Boys/shield-kya/main/assets/report-gateway.png)
```
kya start --no-open # wire only
kya start --force # rewrite MCP blocks
# Receipt change previews (clipped + redacted): on by default for writes
# KYA_DIFF_PREVIEW=0 to disable
```
## One command per host
`kya start` covers Claude Code, Cursor, and any host that reads `.mcp.json`. It also auto-wires the user-level config of every installed host it detects. For the rest, `kya connect` writes the host's own config dialect directly:
```
kya connect claude # ~/.claude.json (merges mcpServers only)
kya connect grok # ~/.grok/config.toml (appends [mcp_servers.shield-kya])
kya connect opencode # ~/.config/opencode/opencode.json
kya connect qwen # ~/.qwen/settings.json
kya connect amp # ~/.config/amp/settings.json
kya connect qwen --project # project scope instead of global
kya connect kiro --force # overwrite an existing shield-kya entry
```
Connect merges. It never rewrites a host config it cannot parse, and it keeps your other servers and keys. Supported hosts: `claude`, `codex`, `grok`, `opencode`, `kilo`, `kiro`, `qwen`, `kimi`, `mastracode`, `amp`, `copilot`, `cursor`. Each wires `serve-mcp --stdio` with `KYA_OFFLINE=1` so the gate starts keyless (no API key). Set `KYA_API_KEY` in the host env when you point at an authenticated plane.
Hosts without a `connect` target still work: `kya wrap --offline -- <agent command>` puts the same evaluate gate in front of any CLI. Per-host recipes with verify steps and troubleshooting live in [docs/hosts/](https://github.com/The-Pixel-Boys/shield-kya/blob/main/docs/hosts).
## Hook interception
`kya start` also wires a `PreToolUse` hook into every installed hook-capable host it detects: Claude Code (`~/.claude/settings.json`, merge-only), Grok (`~/.grok/hooks/shield-kya.json`, kya-managed file), and Kimi Code (`~/.kimi-code/config.toml`, `[[hooks]]` append). Every tool call the agent makes then passes through `kya hook` first: it is evaluated locally (offline, sub-second, no network) and written to the global record (trail). (If you opted in to anonymous usage stats, the hook also starts a detached helper at most once a day; see [Anonymous usage stats](https://github.com/The-Pixel-Boys/shield-kya#anonymous-usage-stats-opt-in-off-by-default).)
Decision mapping: a local never-list **DENY** blocks the tool call (exit `2` plus `hookSpecificOutput` deny JSON with `permissionDecision: "deny"`). **ALLOW** and **REQUIRE\_APPROVE** are written to the record as advisory and the call proceeds. Manual wiring can pass `--strict` on the hook command to also block **REQUIRE\_APPROVE**.
Hooks are fail-open: any hook error or timeout allows the call. They are alerts plus local never-list enforcement, not the sole barrier. Plane enforcement stays on the MCP `kya.policy_evaluate` path. Hooks take effect in new sessions; all three hosts load hooks at session start.
```
kya connect claude --hooks # wire the PreToolUse hook by hand
kya connect grok --hooks
kya connect kimi --hooks
```
## Claude Code plugin
This repo is also a Claude Code plugin marketplace named `shield-kya` with one plugin, `kya`:
```
/plugin marketplace add The-Pixel-Boys/shield-kya
/plugin install kya@shield-kya
```
The plugin is **advisory and fails open**: it records every tool call on the local record (`~/.kya/trail.jsonl`) and blocks only the small never-list. If kya is missing, crashes or times out, the tool call proceeds and nothing is recorded. It evaluates offline, so it has no Hold and no approval. Hosted enforcement is the MCP policy path against a hosted workspace.
Team rollout: commit `extraKnownMarketplaces` (the `shield-kya` GitHub source) and `enabledPlugins` (`"kya@shield-kya": true`) to the repository's `.claude/settings.json`, or force it org-wide with managed settings. Details and limits: [docs/hosts/claude-plugin.md](https://github.com/The-Pixel-Boys/shield-kya/blob/main/docs/hosts/claude-plugin.md).
## GitHub Copilot CLI plugin
**Check first.** If the public repo has no `plugins/kya-copilot` folder yet (every release before the one that ships it), do not install the plugin in Copilot CLI: Copilot then gets the Claude Code plugin, and Copilot CLI 1.0.98 denies every tool call with it ("Denied by preToolUse hook ... (hook errored)"). If you already did, run `copilot plugin uninstall kya@shield-kya`, and use `kya connect copilot` (MCP server only, see [More hosts](https://github.com/The-Pixel-Boys/shield-kya#more-hosts)) until a release ships the folder.
From that release on:
```
copilot plugin marketplace add The-Pixel-Boys/shield-kya
copilot plugin install kya@shield-kya
```
Copilot reads `.plugin/marketplace.json` before `.claude-plugin/marketplace.json`, so `kya@shield-kya` resolves to `plugins/kya-copilot`: an Agent Plugins v1 manifest (`plugin.json`), hooks in `com.github.copilot/hooks/hooks.json` and the MCP server in `mcp.json`. Claude Code and Codex keep loading `plugins/kya` and never see this folder. Same behaviour: advisory, fails open. Copilot denies a tool call when a pre-tool hook exits non-zero. So the hook is a `bash` command that does nothing when `node` is not on Copilot's `PATH`. Otherwise it runs `scripts/copilot-hook.mjs` (which forwards only kya's never-list deny) and turns any exit other than `2` into `0`. Recording needs Node.js 22 or later on that `PATH`. Copilot names MCP tools `<server>-<tool>` (for example `postgres-drop_table`); the never-list does not recognise that form yet, so MCP calls are recorded but not blocked. Rows in the record show the product as `other`.