← 全部工具

agent-cli-detector

热度 65 更新于 开发与构建

Detect whether a JavaScript CLI is running inside a coding agent.

npmauto-collected

安装

npm
npm install -g agent-cli-detector

通过 npm 安装。

agent-cli-detector

Detect whether a JavaScript CLI is running inside a coding agent.

Please open an issue if your coding agent isn't properly detected :)

Installation

npm install agent-cli-detector

Usage

import { detectAgent } from "agent-cli-detector";

const result = detectAgent();

if (result.detected) {
  console.log("The name of the coding agent is:", result.agent.name);
} else {
  console.log("This program is not running inside a coding agent");
}

Supported agents

Officially supported coding agents:

| Name | ID | Session ID | | ----------------------------------------------------------------- | ------------- | ---------- | | Antigravity | antigravity | ✅ | | Bolt | bolt | 🚫 | | Claude Code | claude-code | ✅ | | Cline | cline | 🚫 | | Codex | codex | ✅ | | Cursor | cursor | ✅ | | Devin | devin | 🚫 | | Gemini CLI | gemini | 🚫 | | GitHub Copilot CLI | copilot | ✅ | | Kilo Code | kilocode | ✅ | | Kiro | kiro | ✅ | | OpenCode | opencode | 🚫 | | Pi | pi | 🚫 | | Replit | replit | ✅ | | Rork | rork | 🚫 |

Detection is data-driven: the exact environment variables and process patterns for each agent live in src/agents.ts.

API

detectAgent([options])

Runs detection and returns a DetectionResult:

{
  detected: true,
  agent: {
    id: "cursor",
    name: "Cursor",
    sessionId: "d9e9cd60-2e1c-487c-9bc7-fceee5e9c3a2"
  }
}

result.detected

A boolean. Will be true if the code is running inside a coding agent, otherwise false.

result.agent.id