agent-detector 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"release_type": "major", "release_notes": "Agent Detector is now available as a dependency-free Python package for\nidentifying the AI coding agent driving a process.\n\nIt recognizes Codex, Claude Code, Amp, Pi, OpenCode, Cursor, Gemini CLI, and\nother coding agents using environment evidence. Each result includes a\nnormalized agent name, confidence, source, and signal without returning\nenvironment values. Callers can also require a minimum confidence level.", "additional_info": {"content": "Agent Detector is now available as a dependency-free Python package for\nidentifying the AI coding agent driving a process.\n\nIt recognizes Codex, Claude Code, Amp, Pi, OpenCode, Cursor, Gemini CLI, and\nother coding agents using environment evidence. Each result includes a\nnormalized agent name, confidence, source, and signal without returning\nenvironment values. Callers can also require a minimum confidence level."}, "additional_release_notes": ["This release was contributed by [@patrick91](https://github.com/patrick91) in [#1](https://github.com/patrick91/agent-detector/pull/1)"], "version": "1.0.0", "previous_version": "0.0.0", "hash": "e0f5b31f69c02a9991e2fabc594cbb30e187a97418ddda70f4d87db32f7d4643"}
@@ -0,0 +1,39 @@
1
+ name: Release file check
2
+
3
+ on:
4
+ pull_request_target:
5
+ types: [synchronize, reopened, opened, ready_for_review]
6
+ branches: [main]
7
+ paths:
8
+ - "RELEASE.md"
9
+ - "src/agent_detector/**"
10
+ - "pyproject.toml"
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ check-release:
17
+ name: Release check
18
+ runs-on: ubuntu-latest
19
+ permissions:
20
+ contents: read
21
+ issues: write
22
+ pull-requests: write
23
+ if: github.event.pull_request.user.type != 'Bot'
24
+ steps:
25
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
26
+ with:
27
+ ref: refs/pull/${{ github.event.number }}/merge
28
+ persist-credentials: false
29
+ sparse-checkout: |
30
+ RELEASE.md
31
+ pyproject.toml
32
+ sparse-checkout-cone-mode: false
33
+
34
+ - name: Check for release
35
+ uses: autopub/autopub-action@5fdc82e84c048a82303de6b5c5a9d027665e73cf # v1.1.1
36
+ with:
37
+ command: check
38
+ autopub-version: "1.0.0a60"
39
+ fail-on-missing: "true"
@@ -0,0 +1,69 @@
1
+ name: Release
2
+
3
+ concurrency: release
4
+
5
+ on:
6
+ push:
7
+ branches: [main]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ check-release:
14
+ name: Check for release
15
+ runs-on: ubuntu-latest
16
+ environment: release
17
+ permissions:
18
+ contents: read
19
+ issues: write
20
+ pull-requests: write
21
+ outputs:
22
+ has_release: ${{ steps.check.outputs.has-release }}
23
+ steps:
24
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
25
+
26
+ - name: Check for release
27
+ id: check
28
+ uses: autopub/autopub-action@5fdc82e84c048a82303de6b5c5a9d027665e73cf # v1.1.1
29
+ with:
30
+ command: check
31
+ autopub-version: "1.0.0a60"
32
+
33
+ publish:
34
+ name: Publish to PyPI
35
+ needs: check-release
36
+ if: needs.check-release.outputs.has_release == 'true'
37
+ runs-on: ubuntu-latest
38
+ environment: release
39
+ permissions:
40
+ contents: write
41
+ id-token: write
42
+ issues: write
43
+ pull-requests: write
44
+ steps:
45
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
46
+
47
+ - name: Install uv
48
+ uses: astral-sh/setup-uv@v7
49
+
50
+ - name: Set up Python 3.14
51
+ run: uv python install 3.14
52
+
53
+ - name: Prepare release
54
+ uses: autopub/autopub-action@5fdc82e84c048a82303de6b5c5a9d027665e73cf # v1.1.1
55
+ with:
56
+ command: prepare
57
+ autopub-version: "1.0.0a60"
58
+
59
+ - name: Build package
60
+ uses: autopub/autopub-action@5fdc82e84c048a82303de6b5c5a9d027665e73cf # v1.1.1
61
+ with:
62
+ command: build
63
+ autopub-version: "1.0.0a60"
64
+
65
+ - name: Publish to PyPI
66
+ uses: autopub/autopub-action@5fdc82e84c048a82303de6b5c5a9d027665e73cf # v1.1.1
67
+ with:
68
+ command: publish
69
+ autopub-version: "1.0.0a60"
@@ -0,0 +1,53 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ name: Python ${{ matrix.python-version }}
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
17
+ env:
18
+ UV_PYTHON: ${{ matrix.python-version }}
19
+ steps:
20
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
21
+
22
+ - name: Install uv
23
+ uses: astral-sh/setup-uv@v7
24
+
25
+ - name: Install dependencies
26
+ run: uv sync --all-groups
27
+
28
+ - name: Run tests
29
+ run: uv run pytest
30
+
31
+ quality:
32
+ name: Quality
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
36
+
37
+ - name: Install uv
38
+ uses: astral-sh/setup-uv@v7
39
+
40
+ - name: Install dependencies
41
+ run: uv sync --all-groups
42
+
43
+ - name: Check formatting
44
+ run: uv run ruff format --check .
45
+
46
+ - name: Lint
47
+ run: uv run ruff check .
48
+
49
+ - name: Type check
50
+ run: uv run mypy
51
+
52
+ - name: Build
53
+ run: uv build
@@ -0,0 +1,11 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .coverage
5
+ .mypy_cache/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ .venv/
9
+ build/
10
+ dist/
11
+ htmlcov/
@@ -0,0 +1,17 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.12.4
4
+ hooks:
5
+ - id: ruff-format
6
+ - id: ruff-check
7
+ args: [--fix]
8
+
9
+ - repo: https://github.com/pre-commit/pre-commit-hooks
10
+ rev: v5.0.0
11
+ hooks:
12
+ - id: trailing-whitespace
13
+ - id: check-merge-conflict
14
+ - id: end-of-file-fixer
15
+ - id: check-toml
16
+ - id: no-commit-to-branch
17
+ args: [--branch, main]
@@ -0,0 +1,16 @@
1
+ 1.0.0 - 2026-07-21
2
+ ------------------
3
+
4
+ Agent Detector is now available as a dependency-free Python package for
5
+ identifying the AI coding agent driving a process.
6
+
7
+ It recognizes Codex, Claude Code, Amp, Pi, OpenCode, Cursor, Gemini CLI, and
8
+ other coding agents using environment evidence. Each result includes a
9
+ normalized agent name, confidence, source, and signal without returning
10
+ environment values. Callers can also require a minimum confidence level.
11
+
12
+ This release was contributed by [@patrick91](https://github.com/patrick91) in [#1](https://github.com/patrick91/agent-detector/pull/1)
13
+
14
+ # Changelog
15
+
16
+ This file is managed by [AutoPub](https://github.com/patrick91/autopub).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Patrick Arminio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-detector
3
+ Version: 1.0.0
4
+ Summary: Detect AI coding agents from their execution environment
5
+ Project-URL: Homepage, https://github.com/patrick91/agent-detector
6
+ Project-URL: Repository, https://github.com/patrick91/agent-detector
7
+ Project-URL: Issues, https://github.com/patrick91/agent-detector/issues
8
+ Author: Patrick Arminio
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent,ai,claude,cli,codex,telemetry
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Agent Detector
28
+
29
+ `agent-detector` is a small, dependency-free Python package for detecting which
30
+ AI coding agent is driving the current process.
31
+
32
+ It returns evidence rather than only a boolean, so callers can distinguish an
33
+ explicit identity from a broad environmental hint.
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install agent-detector
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ from agent_detector import detect_agent
45
+
46
+ detection = detect_agent()
47
+
48
+ if detection:
49
+ print(detection.agent) # "codex"
50
+ print(detection.confidence) # "high"
51
+ print(detection.signal) # "CODEX_THREAD_ID"
52
+ ```
53
+
54
+ The returned `DetectionResult` contains:
55
+
56
+ - `agent`: an `AgentName` literal containing a supported agent name
57
+ - `confidence`: `high`, `medium`, or `low`
58
+ - `source`: `environment` or `path`
59
+ - `signal`: the name of the matched signal, never its value
60
+
61
+ Pass a mapping to make detection deterministic in tests:
62
+
63
+ ```python
64
+ assert detect_agent({"OPENCODE": "1"}).agent == "opencode"
65
+ ```
66
+
67
+ Require a minimum confidence when broad environmental hints are not useful:
68
+
69
+ ```python
70
+ detection = detect_agent(minimum_confidence="high")
71
+ ```
72
+
73
+ `minimum_confidence` is typed as `Literal["high", "medium", "low"]` and
74
+ defaults to `"low"`.
75
+
76
+ ## Supported agents
77
+
78
+ | Agent | Signals | Confidence |
79
+ | --- | --- | --- |
80
+ | Explicit override | `AI_AGENT` containing a supported agent name | high |
81
+ | Amp | `AGENT=amp`, `AMP_CURRENT_THREAD_ID` | high / medium |
82
+ | Codex | `CODEX_THREAD_ID`, `CODEX_CI`, `CODEX_SANDBOX` | high |
83
+ | Gemini CLI | `GEMINI_CLI` | high |
84
+ | Copilot CLI | `COPILOT_CLI` | medium |
85
+ | OpenCode | `OPENCODE` | high |
86
+ | Antigravity | `ANTIGRAVITY_AGENT` | medium |
87
+ | Augment CLI | `AUGMENT_AGENT` | medium |
88
+ | Cowork | `CLAUDE_CODE_IS_COWORK` | high |
89
+ | Claude Code | `CLAUDE_CODE_CHILD_SESSION`, `CLAUDECODE`, `CLAUDE_CODE` | high / medium |
90
+ | Cursor | `CURSOR_TRACE_ID` | medium |
91
+ | Cursor CLI | `CURSOR_AGENT`, `CURSOR_EXTENSION_HOST_ROLE=agent-exec` | high / medium |
92
+ | Kiro | `TERM_PROGRAM=kiro` | low |
93
+ | Pi | `.pi/agent` entry in `PATH` | medium |
94
+ | Replit | `REPL_ID` | low |
95
+ | Goose | `GOOSE_PROVIDER` | low |
96
+
97
+ `AI_AGENT` takes precedence over inferred signals when its value is one of the
98
+ supported agent names. Unknown values are ignored.
99
+
100
+ The detector is deliberately ordered. For example, Amp is checked before
101
+ Claude Code because Amp also sets `CLAUDECODE`.
102
+
103
+ ## Important limitations
104
+
105
+ Detection is best-effort. `None` means **unattributed**, not "human". Some
106
+ signals can also be present in an integrated terminal where a person typed the
107
+ command manually.
108
+
109
+ This package detects the execution harness. It cannot determine whether a
110
+ particular skill, plugin, prompt, or model caused the command. Use a separate
111
+ explicit marker when that attribution matters.
112
+
113
+ ## Privacy
114
+
115
+ Environment values such as thread IDs are never returned. A result contains
116
+ only a normalized agent name and the name and category of the matched signal.
117
+
118
+ ## Development
119
+
120
+ ```bash
121
+ uv sync --all-groups
122
+ uv run ruff check .
123
+ uv run ruff format --check .
124
+ uv run mypy
125
+ uv run pytest
126
+ uv build
127
+ ```
@@ -0,0 +1,101 @@
1
+ # Agent Detector
2
+
3
+ `agent-detector` is a small, dependency-free Python package for detecting which
4
+ AI coding agent is driving the current process.
5
+
6
+ It returns evidence rather than only a boolean, so callers can distinguish an
7
+ explicit identity from a broad environmental hint.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install agent-detector
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```python
18
+ from agent_detector import detect_agent
19
+
20
+ detection = detect_agent()
21
+
22
+ if detection:
23
+ print(detection.agent) # "codex"
24
+ print(detection.confidence) # "high"
25
+ print(detection.signal) # "CODEX_THREAD_ID"
26
+ ```
27
+
28
+ The returned `DetectionResult` contains:
29
+
30
+ - `agent`: an `AgentName` literal containing a supported agent name
31
+ - `confidence`: `high`, `medium`, or `low`
32
+ - `source`: `environment` or `path`
33
+ - `signal`: the name of the matched signal, never its value
34
+
35
+ Pass a mapping to make detection deterministic in tests:
36
+
37
+ ```python
38
+ assert detect_agent({"OPENCODE": "1"}).agent == "opencode"
39
+ ```
40
+
41
+ Require a minimum confidence when broad environmental hints are not useful:
42
+
43
+ ```python
44
+ detection = detect_agent(minimum_confidence="high")
45
+ ```
46
+
47
+ `minimum_confidence` is typed as `Literal["high", "medium", "low"]` and
48
+ defaults to `"low"`.
49
+
50
+ ## Supported agents
51
+
52
+ | Agent | Signals | Confidence |
53
+ | --- | --- | --- |
54
+ | Explicit override | `AI_AGENT` containing a supported agent name | high |
55
+ | Amp | `AGENT=amp`, `AMP_CURRENT_THREAD_ID` | high / medium |
56
+ | Codex | `CODEX_THREAD_ID`, `CODEX_CI`, `CODEX_SANDBOX` | high |
57
+ | Gemini CLI | `GEMINI_CLI` | high |
58
+ | Copilot CLI | `COPILOT_CLI` | medium |
59
+ | OpenCode | `OPENCODE` | high |
60
+ | Antigravity | `ANTIGRAVITY_AGENT` | medium |
61
+ | Augment CLI | `AUGMENT_AGENT` | medium |
62
+ | Cowork | `CLAUDE_CODE_IS_COWORK` | high |
63
+ | Claude Code | `CLAUDE_CODE_CHILD_SESSION`, `CLAUDECODE`, `CLAUDE_CODE` | high / medium |
64
+ | Cursor | `CURSOR_TRACE_ID` | medium |
65
+ | Cursor CLI | `CURSOR_AGENT`, `CURSOR_EXTENSION_HOST_ROLE=agent-exec` | high / medium |
66
+ | Kiro | `TERM_PROGRAM=kiro` | low |
67
+ | Pi | `.pi/agent` entry in `PATH` | medium |
68
+ | Replit | `REPL_ID` | low |
69
+ | Goose | `GOOSE_PROVIDER` | low |
70
+
71
+ `AI_AGENT` takes precedence over inferred signals when its value is one of the
72
+ supported agent names. Unknown values are ignored.
73
+
74
+ The detector is deliberately ordered. For example, Amp is checked before
75
+ Claude Code because Amp also sets `CLAUDECODE`.
76
+
77
+ ## Important limitations
78
+
79
+ Detection is best-effort. `None` means **unattributed**, not "human". Some
80
+ signals can also be present in an integrated terminal where a person typed the
81
+ command manually.
82
+
83
+ This package detects the execution harness. It cannot determine whether a
84
+ particular skill, plugin, prompt, or model caused the command. Use a separate
85
+ explicit marker when that attribution matters.
86
+
87
+ ## Privacy
88
+
89
+ Environment values such as thread IDs are never returned. A result contains
90
+ only a normalized agent name and the name and category of the matched signal.
91
+
92
+ ## Development
93
+
94
+ ```bash
95
+ uv sync --all-groups
96
+ uv run ruff check .
97
+ uv run ruff format --check .
98
+ uv run mypy
99
+ uv run pytest
100
+ uv build
101
+ ```
@@ -0,0 +1,11 @@
1
+ ---
2
+ release type: major
3
+ ---
4
+
5
+ Agent Detector is now available as a dependency-free Python package for
6
+ identifying the AI coding agent driving a process.
7
+
8
+ It recognizes Codex, Claude Code, Amp, Pi, OpenCode, Cursor, Gemini CLI, and
9
+ other coding agents using environment evidence. Each result includes a
10
+ normalized agent name, confidence, source, and signal without returning
11
+ environment values. Callers can also require a minimum confidence level.
@@ -0,0 +1,75 @@
1
+ [project]
2
+ name = "agent-detector"
3
+ version = "1.0.0"
4
+ description = "Detect AI coding agents from their execution environment"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.9"
8
+ authors = [{ name = "Patrick Arminio" }]
9
+ dependencies = []
10
+ keywords = ["agent", "ai", "cli", "codex", "claude", "telemetry"]
11
+ classifiers = [
12
+ "Development Status :: 3 - Alpha",
13
+ "Intended Audience :: Developers",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3 :: Only",
17
+ "Programming Language :: Python :: 3.9",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Python :: 3.14",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/patrick91/agent-detector"
28
+ Repository = "https://github.com/patrick91/agent-detector"
29
+ Issues = "https://github.com/patrick91/agent-detector/issues"
30
+
31
+ [build-system]
32
+ requires = ["hatchling"]
33
+ build-backend = "hatchling.build"
34
+
35
+ [dependency-groups]
36
+ dev = [
37
+ "pytest>=8.4.1",
38
+ "pytest-cov>=6.2.1",
39
+ ]
40
+ lint = [
41
+ "mypy>=1.17.1,<2",
42
+ "ruff>=0.12.4",
43
+ ]
44
+
45
+ [tool.ruff]
46
+ fix = true
47
+ line-length = 100
48
+ target-version = "py39"
49
+
50
+ [tool.ruff.lint]
51
+ select = ["B", "E", "F", "I", "RUF", "UP", "W"]
52
+
53
+ [tool.pytest.ini_options]
54
+ addopts = "--cov=agent_detector --cov-report=term-missing"
55
+ testpaths = ["tests"]
56
+ xfail_strict = true
57
+ filterwarnings = ["error"]
58
+
59
+ [tool.coverage.run]
60
+ branch = true
61
+
62
+ [tool.coverage.report]
63
+ fail_under = 100
64
+ show_missing = true
65
+ skip_covered = true
66
+
67
+ [tool.mypy]
68
+ python_version = "3.9"
69
+ files = ["src"]
70
+ strict = true
71
+
72
+ [tool.autopub]
73
+ git-username = "github-actions[bot]"
74
+ git-email = "41898282+github-actions[bot]@users.noreply.github.com"
75
+ plugins = ["autopub.plugins.github", "autopub.plugins.uv"]
@@ -0,0 +1,17 @@
1
+ from agent_detector._detector import (
2
+ KNOWN_AGENTS,
3
+ AgentConfidence,
4
+ AgentName,
5
+ DetectionResult,
6
+ DetectionSource,
7
+ detect_agent,
8
+ )
9
+
10
+ __all__ = [
11
+ "KNOWN_AGENTS",
12
+ "AgentConfidence",
13
+ "AgentName",
14
+ "DetectionResult",
15
+ "DetectionSource",
16
+ "detect_agent",
17
+ ]