Skip to content

Commit 75c0d86

Browse files
committed
docs: polish README
1 parent 8b0bb90 commit 75c0d86

1 file changed

Lines changed: 102 additions & 162 deletions

File tree

README.md

Lines changed: 102 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,73 @@
44
[![Release](https://github.com/forjd/agenthint/actions/workflows/release.yml/badge.svg)](https://github.com/forjd/agenthint/actions/workflows/release.yml)
55
[![npm](https://img.shields.io/npm/v/agenthint?logo=npm&color=cb3837)](https://www.npmjs.com/package/agenthint)
66
[![crates.io](https://img.shields.io/crates/v/agenthint?logo=rust&color=dea584)](https://crates.io/crates/agenthint)
7+
[![PyPI](https://img.shields.io/pypi/v/agenthint?logo=python&color=3776ab)](https://pypi.org/project/agenthint/)
78
[![License](https://img.shields.io/github/license/forjd/agenthint)](LICENSE)
89
[![GitHub Repo stars](https://img.shields.io/github/stars/forjd/agenthint?style=social)](https://github.com/forjd/agenthint)
910

1011
Detect AI agent runtimes and adapt CLI output.
1112

12-
`agenthint` is a small runtime detection spec, CLI, and library for developer tools that want to know when they are probably being run by an AI agent such as Codex, Claude Code, Cursor, Gemini CLI, or Aider.
13+
`agenthint` is a small detection spec, CLI, and multi-language library for developer tools that want to know when they are probably being run by an AI agent such as Codex, Claude Code, Cursor, Gemini CLI, Aider, or another automated coding environment.
1314

14-
It is built for ergonomics, not security. Use it to choose better output defaults for agents; do not use it as a trust boundary.
15+
Use it to choose better defaults for agent-driven runs: structured output, quiet logs, no spinners, no pagers, no interactive prompts, and clearer diagnostics.
1516

16-
## Why
17-
18-
AI agents benefit from different CLI defaults than humans:
19-
20-
- structured output instead of decorative output
21-
- no spinners, pagers, prompts, or browser launches
22-
- stable section markers and clear exit-code meanings
23-
- absolute paths and line-oriented diagnostics
24-
- concise logs that preserve useful debugging context
25-
26-
`agenthint` gives CLIs and libraries a shared way to make that decision.
17+
> Detection is advisory. `agenthint` is for user experience decisions, not authentication, authorization, sandboxing, or policy enforcement.
2718
2819
## Quick Start
2920

21+
Install the CLI:
22+
3023
```sh
3124
npm install -g agenthint
3225
# or
3326
cargo install agenthint
27+
# or
28+
python3 -m pip install agenthint
3429
```
3530

36-
```sh
37-
if agenthint; then
38-
my-tool --json --no-progress
39-
else
40-
my-tool
41-
fi
42-
```
43-
44-
Use it inside another CLI or script to choose agent-friendly output:
31+
Use its exit code in scripts:
4532

4633
```sh
4734
if agenthint >/dev/null; then
48-
exec my-cli --json --no-progress --no-pager "$@"
35+
exec my-tool --json --no-progress --no-pager "$@"
4936
else
50-
exec my-cli "$@"
37+
exec my-tool "$@"
5138
fi
5239
```
5340

54-
For agents and wrappers, the preferred explicit convention is `AI_AGENT`:
41+
Prefer the explicit convention when you control the agent or wrapper:
5542

5643
```sh
5744
AI_AGENT=codex my-tool
5845
AI_AGENT=claude-code my-tool
5946
AI_AGENT=my-custom-agent my-tool
6047
```
6148

49+
## Why
50+
51+
Humans and agents often need different CLI behavior.
52+
53+
| Humans often prefer | Agents often prefer |
54+
| --- | --- |
55+
| Colors, spinners, prompts | Stable, parseable output |
56+
| Pagers and browser launches | Non-interactive execution |
57+
| Decorative progress UI | Line-oriented diagnostics |
58+
| Friendly summaries | Explicit sections and exit codes |
59+
60+
`agenthint` gives tools a shared, explainable way to switch modes without each project inventing its own agent detection logic.
61+
6262
## CLI
6363

6464
```sh
6565
agenthint # exit 0 if an agent is likely detected, otherwise 1
6666
agenthint --json # print the structured detection result
67-
agenthint --explain # print a short explanation
67+
agenthint --explain # print a short human-readable explanation
6868
agenthint doctor # print detection details and setup advice
6969
agenthint doctor --json
70-
# print detection details and setup advice as JSON
7170
agenthint init codex # print the recommended AI_AGENT value
7271
```
7372

74-
Example JSON output:
73+
Example JSON:
7574

7675
```json
7776
{
@@ -82,47 +81,19 @@ Example JSON output:
8281
}
8382
```
8483

85-
## Install
86-
87-
Install from npm:
88-
89-
```sh
90-
npm install -g agenthint
91-
agenthint --json
92-
```
93-
94-
Install from crates.io:
84+
Exit codes:
9585

96-
```sh
97-
cargo install agenthint
98-
agenthint --json
99-
```
86+
| Code | Meaning |
87+
| --- | --- |
88+
| `0` | Agent runtime likely detected |
89+
| `1` | Agent runtime not detected |
90+
| `2` | Invalid usage or detection error |
10091

101-
Install from PyPI:
92+
Setup-only commands such as `agenthint init <agent>` exit `0`.
10293

103-
```sh
104-
python3 -m pip install agenthint
105-
agenthint --json
106-
```
107-
108-
Install the latest native binary from GitHub Releases:
109-
110-
```sh
111-
curl -fsSL https://raw.githubusercontent.com/forjd/agenthint/main/install.sh | sh
112-
```
94+
## Libraries
11395

114-
By default, the install script downloads the latest `agenthint-v*` GitHub Release asset for your platform. Set `AGENTHINT_VERSION` to install a specific release tag.
115-
116-
Override the install directory or release version:
117-
118-
```sh
119-
AGENTHINT_INSTALL_DIR=/usr/local/bin sh install.sh
120-
AGENTHINT_VERSION=agenthint-vX.Y.Z sh install.sh
121-
```
122-
123-
Native binaries are built by GitHub Actions for release assets. The installer verifies `SHA256SUMS` when the selected release provides it.
124-
125-
## TypeScript API
96+
### TypeScript
12697

12798
```ts
12899
import { detectAgent } from "agenthint";
@@ -134,9 +105,7 @@ if (result.isAgent) {
134105
}
135106
```
136107

137-
## Rust API
138-
139-
The repository also contains a Rust implementation under `crates/agenthint`.
108+
### Rust
140109

141110
```rust
142111
use agenthint::detect_agent;
@@ -148,13 +117,7 @@ if result.is_agent {
148117
}
149118
```
150119

151-
Run the Rust CLI locally:
152-
153-
```sh
154-
cargo run -q -p agenthint -- --json
155-
```
156-
157-
## Python API
120+
### Python
158121

159122
```python
160123
from agenthint import detect_agent
@@ -166,124 +129,101 @@ if result.is_agent:
166129
pass
167130
```
168131

169-
## Detection Model
132+
## Install
170133

171-
The result includes:
134+
### npm
172135

173-
- `isAgent`: whether an agent runtime is likely detected
174-
- `agent`: known or custom agent name
175-
- `confidence`: a number from `0` to `1`
176-
- `signals`: diagnostic signal names, never secret values
136+
```sh
137+
npm install -g agenthint
138+
agenthint --json
139+
```
177140

178-
Detection priority:
141+
### crates.io
179142

180-
1. `AGENTHINT_DISABLE`
181-
2. `AGENTHINT_FORCE`
182-
3. explicit `AI_AGENT`
183-
4. known environment signals
184-
5. documented filesystem signals
185-
6. low-confidence parent process signals
186-
7. low-confidence stdio hints
187-
188-
## Supported Agents
189-
190-
Current known agent names include:
191-
192-
- Codex
193-
- Claude Code
194-
- Cowork
195-
- Cursor
196-
- Gemini CLI
197-
- Aider
198-
- Augment CLI
199-
- AMP
200-
- OpenCode
201-
- OpenClaw
202-
- GitHub Copilot
203-
- Replit
204-
- Devin
205-
- Google Antigravity
206-
- Pi
207-
- Kiro CLI
208-
- Windsurf
209-
- Cline
210-
- Roo Code
211-
- Kilo Code
212-
- Mistral Vibe
213-
- v0
143+
```sh
144+
cargo install agenthint
145+
agenthint --json
146+
```
214147

215-
Custom agents are supported through any non-empty `AI_AGENT` value.
148+
### PyPI
216149

217-
See [docs/agents.md](docs/agents.md) for recommended `AI_AGENT` values.
150+
```sh
151+
python3 -m pip install agenthint
152+
agenthint --json
153+
```
218154

219-
See [docs/integrations.md](docs/integrations.md) for Bash, Zsh, Fish, Node.js, Rust, and Python integration snippets.
155+
### Native binary
220156

221-
See [docs/signals.md](docs/signals.md) for the signal registry and confidence levels.
157+
```sh
158+
curl -fsSL https://raw.githubusercontent.com/forjd/agenthint/main/install.sh | sh
159+
```
222160

223-
## Principles
161+
The install script downloads the latest `agenthint-v*` GitHub Release asset for your platform and verifies `SHA256SUMS` when the selected release provides them.
224162

225-
- Detection is advisory and can be spoofed.
226-
- Prefer `AI_AGENT` when an agent can set an explicit hint.
227-
- Prefer explicit environment signals over brittle heuristics.
228-
- Return confidence, not false certainty.
229-
- Print signal names, not environment variable values.
230-
- Keep output quiet and machine-readable when requested.
231-
- Make the convention useful across languages and toolchains.
163+
Override the install directory or version:
232164

233-
## Packages
234-
235-
Current:
165+
```sh
166+
AGENTHINT_INSTALL_DIR=/usr/local/bin sh install.sh
167+
AGENTHINT_VERSION=agenthint-vX.Y.Z sh install.sh
168+
```
236169

237-
- `agenthint` JavaScript/TypeScript package
238-
- `agenthint` Rust crate and CLI implementation
239-
- `agenthint` Python package
170+
## Detection Model
240171

241-
Planned:
172+
Every detection result includes:
242173

243-
- standalone native binary releases
174+
| Field | Description |
175+
| --- | --- |
176+
| `isAgent` | Whether an agent runtime is likely detected |
177+
| `agent` | Known or custom agent name, when available |
178+
| `confidence` | A number from `0` to `1` |
179+
| `signals` | Diagnostic signal names, never secret values |
244180

245-
The packages use the unscoped `agenthint` name across npm, crates.io, and PyPI. If the npm name becomes unavailable before first publish, the fallback package name is `@forjd/agenthint`.
181+
Detection priority:
246182

247-
## CI and Releases
183+
1. `AGENTHINT_DISABLE`
184+
2. `AGENTHINT_FORCE`
185+
3. Explicit `AI_AGENT`
186+
4. Known environment signals
187+
5. Documented filesystem signals
188+
6. Low-confidence parent process signals
189+
7. Low-confidence stdio hints
248190

249-
GitHub Actions runs formatting, linting, TypeScript tests, Rust tests, Python tests, npm package checks, Python package build checks, and `cargo publish --dry-run`.
191+
Known agents include Codex, Claude Code, Cursor, Gemini CLI, Aider, Augment CLI, AMP, OpenCode, OpenClaw, GitHub Copilot, Replit, Devin, Google Antigravity, Pi, Kiro CLI, Windsurf, Cline, Roo Code, Kilo Code, Mistral Vibe, v0, and Cowork.
250192

251-
Releases use release-please with Conventional Commits. npm and PyPI publishing use trusted publishing via GitHub Actions OIDC, so no long-lived package tokens are required.
193+
Custom agents are supported through any non-empty `AI_AGENT` value.
252194

253-
See [docs/releases.md](docs/releases.md) for release details.
195+
## Docs
254196

255-
## Development
197+
- [Agent integration notes](docs/agents.md): recommended `AI_AGENT` values
198+
- [Integration snippets](docs/integrations.md): Bash, Zsh, Fish, Node.js, Rust, and Python examples
199+
- [Signal registry](docs/signals.md): known signals and confidence levels
200+
- [Detection spec](SPEC.md): the portable detection contract
256201

257-
Use [mise](https://mise.jdx.dev/) for local toolchain versions:
202+
## Principles
258203

259-
```sh
260-
mise install
261-
```
204+
- Prefer explicit `AI_AGENT` support over heuristics.
205+
- Return confidence, not false certainty.
206+
- Print signal names, not environment variable values.
207+
- Keep filesystem probes documented and configurable.
208+
- Keep requested machine-readable output quiet and stable.
209+
- Treat detection as a hint, never as a security boundary.
262210

263-
Install dependencies and run checks:
211+
## Development
264212

265213
```sh
266-
npm install
267-
npm run check
214+
mise install
215+
mise exec -- npm run check
268216
```
269217

270-
Useful commands:
218+
Useful scripts:
271219

272220
```sh
221+
npm run build
273222
npm run format
274223
npm run lint
275-
npm test
276-
npm run python:build
277-
npm run python:test
278-
npm run generate:rules
224+
npm run test
225+
npm run check
279226
cargo test --workspace
280-
cargo clippy --workspace --all-targets -- -D warnings
281227
```
282228

283-
## Security
284-
285-
`agenthint` is not an authentication, authorization, sandboxing, or policy tool. Environment variables, parent process names, and filesystem markers can be spoofed. Treat all results as UX hints only.
286-
287-
## License
288-
289-
MIT © Forjd
229+
Contributions are welcome. Please keep detection results explainable, avoid printing secret-bearing environment values, and update the docs when adding or changing signals.

0 commit comments

Comments
 (0)