Skip to content

Commit 9809532

Browse files
committed
Add validate command.
1 parent 9b4c94b commit 9809532

6 files changed

Lines changed: 334 additions & 30 deletions

File tree

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# AgentCI CLI
2+
3+
Command-line interface for interacting with AgentCI.
4+
5+
## Installation
6+
7+
```bash
8+
uv pip add agentci
9+
```
10+
11+
## Usage
12+
13+
```bash
14+
agentci <command> [options]
15+
```
16+
17+
### Commands
18+
19+
#### `validate`
20+
21+
Validate all AgentCI evaluation configurations in a directory:
22+
23+
```bash
24+
# Validate configs in current directory
25+
agentci validate
26+
27+
# Validate configs in specific directory
28+
agentci validate /path/to/repository
29+
```
30+
31+
By default, AgentCI looks for configurations in `.agentci/evals/`. You can customize this location using the `AGENTCI_CLIENT_BASE_PATH` environment variable:
32+
33+
```bash
34+
AGENTCI_CLIENT_BASE_PATH="custom/path" agentci validate
35+
```
36+
37+
## License
38+
39+
MIT License - see [LICENSE](LICENSE) for details.
40+
41+
## Contributing
42+
43+
Contributions are welcome! Please feel free to submit a Pull Request.
44+
45+
## Links
46+
47+
- Website: <https://agent-ci.com>
48+
- Issues: <https://github.com/Agent-CI/cli/issues>

agentci/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

agentci/cli.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

pyproject.toml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
[build-system]
2-
requires = ["setuptools>=61.0", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "agentci"
7-
version = "0.1.0"
7+
version = "0.1.1"
88
description = "Agent CI command-line interface"
99
authors = [
1010
{name = "Agent CI", email = "hello@agent-ci.com"},
1111
{name = "Travis Dent", email = "root@a10k.co"}
1212
]
1313
readme = "README.md"
14-
requires-python = ">=3.10"
14+
requires-python = ">=3.11"
1515
license = {text = "MIT"}
1616
keywords = ["agentci", "ci", "testing", "agents", "cli"]
1717
classifiers = [
1818
"Development Status :: 3 - Alpha",
1919
"Intended Audience :: Developers",
2020
"Operating System :: OS Independent",
2121
"Programming Language :: Python :: 3",
22-
"Programming Language :: Python :: 3.10",
2322
"Programming Language :: Python :: 3.11",
2423
"Programming Language :: Python :: 3.12",
2524
]
26-
dependencies = []
25+
dependencies = [
26+
"agentci-client-config==0.1.0",
27+
]
2728

2829
[project.urls]
2930
Homepage = "https://agent-ci.com"
@@ -33,6 +34,12 @@ Issues = "https://github.com/Agent-CI/cli/issues"
3334
[project.scripts]
3435
agentci = "agentci.cli:main"
3536

36-
[tool.setuptools.packages.find]
37-
where = ["."]
38-
include = ["agentci*"]
37+
[tool.hatch.build.targets.wheel]
38+
packages = ["src/agentci"]
39+
40+
[tool.ruff]
41+
line-length = 110
42+
target-version = "py311"
43+
44+
[tool.ruff.format]
45+
quote-style = "preserve"

src/agentci/cli/__init__.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import argparse
2+
import sys
3+
from pathlib import Path
4+
from importlib.metadata import version
5+
6+
from agentci.client_config import discover_evaluations
7+
8+
__version__ = version("agentci")
9+
10+
11+
12+
def validate_command(args):
13+
"""Validate AgentCI configuration files in the current directory."""
14+
# Use the provided path or current working directory
15+
repo_path = Path(args.path) if args.path else Path.cwd()
16+
17+
if not repo_path.exists():
18+
print(f"Error: Directory '{repo_path}' does not exist.", file=sys.stderr)
19+
return 1
20+
21+
if not repo_path.is_dir():
22+
print(f"Error: '{repo_path}' is not a directory.", file=sys.stderr)
23+
return 1
24+
25+
print(f"Validating AgentCI configurations in: {repo_path}")
26+
27+
try:
28+
evaluations = discover_evaluations(repo_path)
29+
30+
if not evaluations:
31+
print("\nNo evaluation configurations found.")
32+
print(f"Place your .toml files in: {repo_path}/.agentci/evals/")
33+
return 0
34+
35+
print(f"\n✓ Found {len(evaluations)} valid evaluation configuration(s):")
36+
for eval_config in evaluations:
37+
print(f" - {eval_config.name} ({eval_config.type.value}): {eval_config.description}")
38+
print(f" File: {eval_config.file_path}")
39+
print(f" Targets: {len(eval_config.targets.agents)} agent(s), {len(eval_config.targets.tools)} tool(s)")
40+
print(f" Cases: {len(eval_config.cases)}")
41+
42+
print(f"\n✓ All configurations are valid!")
43+
return 0
44+
45+
except ValueError as e:
46+
print(f"\n✗ Validation failed: {e}", file=sys.stderr)
47+
return 1
48+
except Exception as e:
49+
print(f"\n✗ Unexpected error: {e}", file=sys.stderr)
50+
return 1
51+
52+
53+
def main():
54+
parser = argparse.ArgumentParser(
55+
description=f"Agent CI CLI v{__version__}",
56+
prog="agentci",
57+
)
58+
parser.add_argument(
59+
"--version",
60+
action="version",
61+
version=f"%(prog)s {__version__}",
62+
)
63+
64+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
65+
66+
# Validate command
67+
validate_parser = subparsers.add_parser(
68+
"validate",
69+
help="Validate AgentCI configuration files",
70+
description="Discover and validate AgentCI evaluation configuration files in a directory",
71+
)
72+
validate_parser.add_argument(
73+
"path",
74+
nargs="?",
75+
default=None,
76+
help="Path to the repository (defaults to current directory)",
77+
)
78+
79+
args = parser.parse_args()
80+
81+
if args.command == "validate":
82+
return validate_command(args)
83+
else:
84+
# No command specified, show help
85+
parser.print_help()
86+
return 0
87+
88+
89+
if __name__ == "__main__":
90+
sys.exit(main())

0 commit comments

Comments
 (0)