bat-cli 0.1.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.
Files changed (54) hide show
  1. bat_cli-0.1.0/PKG-INFO +231 -0
  2. bat_cli-0.1.0/README.md +217 -0
  3. bat_cli-0.1.0/pyproject.toml +49 -0
  4. bat_cli-0.1.0/setup.cfg +4 -0
  5. bat_cli-0.1.0/src/add/__init__.py +3 -0
  6. bat_cli-0.1.0/src/add/client.py +16 -0
  7. bat_cli-0.1.0/src/bat_cli.egg-info/PKG-INFO +231 -0
  8. bat_cli-0.1.0/src/bat_cli.egg-info/SOURCES.txt +52 -0
  9. bat_cli-0.1.0/src/bat_cli.egg-info/dependency_links.txt +1 -0
  10. bat_cli-0.1.0/src/bat_cli.egg-info/entry_points.txt +2 -0
  11. bat_cli-0.1.0/src/bat_cli.egg-info/requires.txt +7 -0
  12. bat_cli-0.1.0/src/bat_cli.egg-info/top_level.txt +8 -0
  13. bat_cli-0.1.0/src/build/__init__.py +3 -0
  14. bat_cli-0.1.0/src/build/build.py +79 -0
  15. bat_cli-0.1.0/src/cli.py +260 -0
  16. bat_cli-0.1.0/src/create/__init__.py +3 -0
  17. bat_cli-0.1.0/src/create/agent.py +312 -0
  18. bat_cli-0.1.0/src/create/templates/agent/.dockerignore +3 -0
  19. bat_cli-0.1.0/src/create/templates/agent/.env.template +4 -0
  20. bat_cli-0.1.0/src/create/templates/agent/.python-version +1 -0
  21. bat_cli-0.1.0/src/create/templates/agent/Dockerfile +37 -0
  22. bat_cli-0.1.0/src/create/templates/agent/Makefile +34 -0
  23. bat_cli-0.1.0/src/create/templates/agent/README.md +1 -0
  24. bat_cli-0.1.0/src/create/templates/agent/__main__.py +2 -0
  25. bat_cli-0.1.0/src/create/templates/agent/agent.json.template +12 -0
  26. bat_cli-0.1.0/src/create/templates/agent/agent.spec +45 -0
  27. bat_cli-0.1.0/src/create/templates/agent/config.yaml +1 -0
  28. bat_cli-0.1.0/src/create/templates/agent/llm_client.py.template +36 -0
  29. bat_cli-0.1.0/src/create/templates/agent/pyproject.toml.template +9 -0
  30. bat_cli-0.1.0/src/create/templates/agent/src/__init__.py +0 -0
  31. bat_cli-0.1.0/src/create/templates/agent/src/graph.py +50 -0
  32. bat_cli-0.1.0/src/create/templates/agent/src/llm_clients/__init__.py +0 -0
  33. bat_cli-0.1.0/src/create/templates/agent/tests/__init__.py +0 -0
  34. bat_cli-0.1.0/src/eval/__init__.py +1 -0
  35. bat_cli-0.1.0/src/eval/commands.py +562 -0
  36. bat_cli-0.1.0/src/eval/engine/__init__.py +1 -0
  37. bat_cli-0.1.0/src/eval/engine/adapter.py +251 -0
  38. bat_cli-0.1.0/src/eval/engine/bench_runner.py +149 -0
  39. bat_cli-0.1.0/src/eval/engine/contracts.py +115 -0
  40. bat_cli-0.1.0/src/eval/engine/eval_config.py +294 -0
  41. bat_cli-0.1.0/src/eval/engine/evaluator.py +85 -0
  42. bat_cli-0.1.0/src/eval/engine/metrics/__init__.py +1 -0
  43. bat_cli-0.1.0/src/eval/engine/metrics/llm_evaluators.py +383 -0
  44. bat_cli-0.1.0/src/eval/engine/metrics/metrics.py +135 -0
  45. bat_cli-0.1.0/src/eval/engine/metrics/qualitative_helpers.py +64 -0
  46. bat_cli-0.1.0/src/eval/engine/orchestrator.py +157 -0
  47. bat_cli-0.1.0/src/eval/engine/plotter.py +347 -0
  48. bat_cli-0.1.0/src/image_defaults.py +80 -0
  49. bat_cli-0.1.0/src/push/__init__.py +3 -0
  50. bat_cli-0.1.0/src/push/push.py +58 -0
  51. bat_cli-0.1.0/src/set/__init__.py +3 -0
  52. bat_cli-0.1.0/src/set/env.py +50 -0
  53. bat_cli-0.1.0/tests/test_create_new_agent.py +477 -0
  54. bat_cli-0.1.0/tests/test_eval_commands.py +483 -0
bat_cli-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.4
2
+ Name: bat-cli
3
+ Version: 0.1.0
4
+ Summary: CLI tool to interact with BAT agents
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: typer>=0.12.3
8
+ Requires-Dist: bat-adk>=2026.06rc1
9
+ Requires-Dist: bat-adk[openai]
10
+ Requires-Dist: a2a-sdk>=1.0.0
11
+ Requires-Dist: python-dotenv>=1.0.1
12
+ Requires-Dist: typing-extensions>=4.12.0
13
+ Requires-Dist: matplotlib>=3.8
14
+
15
+ # bat-cli
16
+
17
+ A CLI tool for creating, building, and evaluating BAT agent projects.
18
+
19
+ ## Prerequisites
20
+
21
+ - Python and [uv](https://docs.astral.sh/uv/) installed
22
+ - Docker installed (required for `bat build` and `bat push`)
23
+ - For evaluation commands: an existing BAT agent root containing `agent.json`, `config.yaml`, and `src/graph.py`
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ### Option A — build and install a standalone binary (Linux/macOS)
30
+
31
+ Run the helper script from the repo root:
32
+
33
+ ```bash
34
+ bash cli/build_and_install.sh
35
+ ```
36
+
37
+ This will:
38
+
39
+ 1. Sync `dev` and `packaging` dependency groups via `uv`.
40
+ 2. Build a one-file executable with PyInstaller.
41
+ 3. Move it to `~/.local/bin/bat` (uses `sudo` only when necessary).
42
+
43
+ Make sure `~/.local/bin` is in your `PATH`:
44
+
45
+ ```bash
46
+ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # or ~/.zshrc
47
+ source ~/.bashrc
48
+ ```
49
+
50
+ Then verify:
51
+
52
+ ```bash
53
+ bat --help
54
+ ```
55
+
56
+ ### Option B — build manually
57
+
58
+ ```bash
59
+ uv sync --group dev --group packaging
60
+ uv run pyinstaller --clean --noconfirm bat_cli.spec
61
+ # binary is at dist/bat (Linux/macOS) or dist/bat.exe (Windows)
62
+ ```
63
+
64
+ On **Windows**, copy `dist/bat.exe` to a folder on your `PATH` (e.g. `C:\tools\bat`) and open a new terminal.
65
+
66
+ > PyInstaller builds are OS-specific — build on each target OS.
67
+
68
+ ### Option C — run without installing (development)
69
+
70
+ ```bash
71
+ uv sync --group dev
72
+ uv run bat --help
73
+ ```
74
+
75
+ All examples below show `bat ...`; replace with `uv run bat ...` when using this option.
76
+
77
+ ---
78
+
79
+ ## Command Tree
80
+
81
+ ```
82
+ bat
83
+ ├── init
84
+ │ └── agent
85
+ │ ├── [name=default]
86
+ │ ├── --clients, -c
87
+ │ ├── --output-dir, -o
88
+ │ ├── --force, -f
89
+ │ ├── --port
90
+ │ ├── --model
91
+ │ └── --model-provider
92
+ ├── add
93
+ │ └── client
94
+ │ ├── <clients>
95
+ │ └── --force, -f
96
+ ├── set
97
+ │ └── env
98
+ │ ├── --port
99
+ │ ├── --model
100
+ │ ├── --model-provider
101
+ │ ├── --docker-registry
102
+ │ └── --repo
103
+ ├── eval
104
+ │ ├── init
105
+ │ │ └── --force, -f
106
+ │ └── run
107
+ ├── build
108
+ │ ├── --context, -C
109
+ │ ├── --docker-registry
110
+ │ ├── --repo
111
+ │ ├── --tag
112
+ │ ├── --version
113
+ │ └── --no-cache
114
+ └── push
115
+ ├── --context, -C
116
+ ├── --docker-registry
117
+ ├── --repo
118
+ └── --tag
119
+ ```
120
+
121
+ Built-in help is available at every level:
122
+
123
+ ```bash
124
+ bat --help
125
+ bat init agent --help
126
+ bat build --help
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Workflows
132
+
133
+ ### 1. Create a new agent
134
+
135
+ ```bash
136
+ # default name
137
+ bat init agent
138
+
139
+ # custom name
140
+ bat init agent my_agent
141
+
142
+ # specific output directory
143
+ bat init agent my_agent --output-dir .
144
+
145
+ # pre-generate LLM clients
146
+ bat init agent my_agent --clients reformulator,planner,executor
147
+ ```
148
+
149
+ ### 2. Add clients to an existing agent
150
+
151
+ Run from the agent root (must contain `src/llm_clients/`):
152
+
153
+ ```bash
154
+ bat add client planner,executor
155
+
156
+ # overwrite existing files
157
+ bat add client planner,executor --force
158
+ ```
159
+
160
+ ### 3. Update agent environment variables
161
+
162
+ Run from the agent root (updates or creates `.env`):
163
+
164
+ ```bash
165
+ bat set env --port 8080 --model gpt-4.1-mini --model-provider openai
166
+
167
+ # also set Docker defaults for build/push
168
+ bat set env --docker-registry hub.bubbleran.com --repo orama/labs/my-agent
169
+ ```
170
+
171
+ ### 4. Build and push a Docker image
172
+
173
+ ```bash
174
+ bat build --context ./my_agent --docker-registry hub.bubbleran.com --repo orama/labs/my-agent --tag latest
175
+
176
+ # no-cache build with version build-arg
177
+ bat build --context ./my_agent --repo orama/labs/my-agent --tag v1 --version 1.0.0 --no-cache
178
+
179
+ bat push --context ./my_agent --docker-registry hub.bubbleran.com --repo orama/labs/my-agent --tag latest
180
+ ```
181
+
182
+ If `BAT_DOCKER_REGISTRY` and `BAT_DOCKER_REPO` are already set in `.env` or the shell, `--docker-registry` and `--repo` can be omitted.
183
+
184
+ **Precedence** (both `--docker-registry` / `--repo`):
185
+
186
+ 1. CLI flag
187
+ 2. Shell environment variable (`BAT_DOCKER_REGISTRY` / `BAT_DOCKER_REPO`)
188
+ 3. `.env` file in the current directory
189
+ 4. Hardcoded default (`default_registry` / `default-repository/<project-name>`)
190
+
191
+ ### 5. Run evaluation
192
+
193
+ From an existing agent root:
194
+
195
+ ```bash
196
+ # scaffold evaluation files
197
+ bat eval init
198
+
199
+ # run evaluation
200
+ bat eval run
201
+ ```
202
+
203
+ `eval init` creates:
204
+
205
+ - `eval/eval.yaml`
206
+ - `eval/input/tasks.json`
207
+ - `eval/output/`
208
+
209
+ Minimal `eval/eval.yaml`:
210
+
211
+ ```yaml
212
+ evaluation:
213
+ dataset: eval/input/tasks.json
214
+ output_dir: eval/output
215
+ k: 1
216
+ qualitative: true
217
+ save_attempts: false
218
+
219
+ judge:
220
+ provider: ollama
221
+ model: your-judge-model
222
+ base_url: http://localhost:11434
223
+
224
+ models:
225
+ - provider: openai
226
+ model: your-model-name
227
+ ```
228
+
229
+ `eval run` requires the agent virtual environment at `.venv/bin/python` (`.venv/Scripts/python.exe` on Windows).
230
+
231
+ For model that requires API_KEYS set it into the agent `.env` under <PROVIDER>\_API_KEY.
@@ -0,0 +1,217 @@
1
+ # bat-cli
2
+
3
+ A CLI tool for creating, building, and evaluating BAT agent projects.
4
+
5
+ ## Prerequisites
6
+
7
+ - Python and [uv](https://docs.astral.sh/uv/) installed
8
+ - Docker installed (required for `bat build` and `bat push`)
9
+ - For evaluation commands: an existing BAT agent root containing `agent.json`, `config.yaml`, and `src/graph.py`
10
+
11
+ ---
12
+
13
+ ## Installation
14
+
15
+ ### Option A — build and install a standalone binary (Linux/macOS)
16
+
17
+ Run the helper script from the repo root:
18
+
19
+ ```bash
20
+ bash cli/build_and_install.sh
21
+ ```
22
+
23
+ This will:
24
+
25
+ 1. Sync `dev` and `packaging` dependency groups via `uv`.
26
+ 2. Build a one-file executable with PyInstaller.
27
+ 3. Move it to `~/.local/bin/bat` (uses `sudo` only when necessary).
28
+
29
+ Make sure `~/.local/bin` is in your `PATH`:
30
+
31
+ ```bash
32
+ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # or ~/.zshrc
33
+ source ~/.bashrc
34
+ ```
35
+
36
+ Then verify:
37
+
38
+ ```bash
39
+ bat --help
40
+ ```
41
+
42
+ ### Option B — build manually
43
+
44
+ ```bash
45
+ uv sync --group dev --group packaging
46
+ uv run pyinstaller --clean --noconfirm bat_cli.spec
47
+ # binary is at dist/bat (Linux/macOS) or dist/bat.exe (Windows)
48
+ ```
49
+
50
+ On **Windows**, copy `dist/bat.exe` to a folder on your `PATH` (e.g. `C:\tools\bat`) and open a new terminal.
51
+
52
+ > PyInstaller builds are OS-specific — build on each target OS.
53
+
54
+ ### Option C — run without installing (development)
55
+
56
+ ```bash
57
+ uv sync --group dev
58
+ uv run bat --help
59
+ ```
60
+
61
+ All examples below show `bat ...`; replace with `uv run bat ...` when using this option.
62
+
63
+ ---
64
+
65
+ ## Command Tree
66
+
67
+ ```
68
+ bat
69
+ ├── init
70
+ │ └── agent
71
+ │ ├── [name=default]
72
+ │ ├── --clients, -c
73
+ │ ├── --output-dir, -o
74
+ │ ├── --force, -f
75
+ │ ├── --port
76
+ │ ├── --model
77
+ │ └── --model-provider
78
+ ├── add
79
+ │ └── client
80
+ │ ├── <clients>
81
+ │ └── --force, -f
82
+ ├── set
83
+ │ └── env
84
+ │ ├── --port
85
+ │ ├── --model
86
+ │ ├── --model-provider
87
+ │ ├── --docker-registry
88
+ │ └── --repo
89
+ ├── eval
90
+ │ ├── init
91
+ │ │ └── --force, -f
92
+ │ └── run
93
+ ├── build
94
+ │ ├── --context, -C
95
+ │ ├── --docker-registry
96
+ │ ├── --repo
97
+ │ ├── --tag
98
+ │ ├── --version
99
+ │ └── --no-cache
100
+ └── push
101
+ ├── --context, -C
102
+ ├── --docker-registry
103
+ ├── --repo
104
+ └── --tag
105
+ ```
106
+
107
+ Built-in help is available at every level:
108
+
109
+ ```bash
110
+ bat --help
111
+ bat init agent --help
112
+ bat build --help
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Workflows
118
+
119
+ ### 1. Create a new agent
120
+
121
+ ```bash
122
+ # default name
123
+ bat init agent
124
+
125
+ # custom name
126
+ bat init agent my_agent
127
+
128
+ # specific output directory
129
+ bat init agent my_agent --output-dir .
130
+
131
+ # pre-generate LLM clients
132
+ bat init agent my_agent --clients reformulator,planner,executor
133
+ ```
134
+
135
+ ### 2. Add clients to an existing agent
136
+
137
+ Run from the agent root (must contain `src/llm_clients/`):
138
+
139
+ ```bash
140
+ bat add client planner,executor
141
+
142
+ # overwrite existing files
143
+ bat add client planner,executor --force
144
+ ```
145
+
146
+ ### 3. Update agent environment variables
147
+
148
+ Run from the agent root (updates or creates `.env`):
149
+
150
+ ```bash
151
+ bat set env --port 8080 --model gpt-4.1-mini --model-provider openai
152
+
153
+ # also set Docker defaults for build/push
154
+ bat set env --docker-registry hub.bubbleran.com --repo orama/labs/my-agent
155
+ ```
156
+
157
+ ### 4. Build and push a Docker image
158
+
159
+ ```bash
160
+ bat build --context ./my_agent --docker-registry hub.bubbleran.com --repo orama/labs/my-agent --tag latest
161
+
162
+ # no-cache build with version build-arg
163
+ bat build --context ./my_agent --repo orama/labs/my-agent --tag v1 --version 1.0.0 --no-cache
164
+
165
+ bat push --context ./my_agent --docker-registry hub.bubbleran.com --repo orama/labs/my-agent --tag latest
166
+ ```
167
+
168
+ If `BAT_DOCKER_REGISTRY` and `BAT_DOCKER_REPO` are already set in `.env` or the shell, `--docker-registry` and `--repo` can be omitted.
169
+
170
+ **Precedence** (both `--docker-registry` / `--repo`):
171
+
172
+ 1. CLI flag
173
+ 2. Shell environment variable (`BAT_DOCKER_REGISTRY` / `BAT_DOCKER_REPO`)
174
+ 3. `.env` file in the current directory
175
+ 4. Hardcoded default (`default_registry` / `default-repository/<project-name>`)
176
+
177
+ ### 5. Run evaluation
178
+
179
+ From an existing agent root:
180
+
181
+ ```bash
182
+ # scaffold evaluation files
183
+ bat eval init
184
+
185
+ # run evaluation
186
+ bat eval run
187
+ ```
188
+
189
+ `eval init` creates:
190
+
191
+ - `eval/eval.yaml`
192
+ - `eval/input/tasks.json`
193
+ - `eval/output/`
194
+
195
+ Minimal `eval/eval.yaml`:
196
+
197
+ ```yaml
198
+ evaluation:
199
+ dataset: eval/input/tasks.json
200
+ output_dir: eval/output
201
+ k: 1
202
+ qualitative: true
203
+ save_attempts: false
204
+
205
+ judge:
206
+ provider: ollama
207
+ model: your-judge-model
208
+ base_url: http://localhost:11434
209
+
210
+ models:
211
+ - provider: openai
212
+ model: your-model-name
213
+ ```
214
+
215
+ `eval run` requires the agent virtual environment at `.venv/bin/python` (`.venv/Scripts/python.exe` on Windows).
216
+
217
+ For model that requires API_KEYS set it into the agent `.env` under <PROVIDER>\_API_KEY.
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "bat-cli"
7
+ version = "0.1.0"
8
+ description = "CLI tool to interact with BAT agents"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ dependencies = [
12
+ "typer>=0.12.3",
13
+ "bat-adk>=2026.06rc1",
14
+ "bat-adk[openai]",
15
+ "a2a-sdk>=1.0.0",
16
+ "python-dotenv>=1.0.1",
17
+ "typing-extensions>=4.12.0",
18
+ "matplotlib>=3.8",
19
+ ]
20
+
21
+ [dependency-groups]
22
+ dev = [
23
+ "pytest>=8.0",
24
+ ]
25
+ packaging = [
26
+ "pyinstaller>=6.0",
27
+ ]
28
+
29
+ [project.scripts]
30
+ bat = "cli:main"
31
+
32
+ [tool.setuptools]
33
+ package-dir = {"" = "src"}
34
+ py-modules = ["cli", "image_defaults"]
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
38
+
39
+ [tool.setuptools.package-data]
40
+ create = [
41
+ "templates/agent/*",
42
+ "templates/agent/.*",
43
+ "templates/agent/src/*",
44
+ "templates/agent/src/llm_clients/*",
45
+ "templates/agent/tests/*",
46
+ ]
47
+
48
+ [tool.pytest.ini_options]
49
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .client import add_clients_to_existing_agent
2
+
3
+ __all__ = ["add_clients_to_existing_agent"]
@@ -0,0 +1,16 @@
1
+ from pathlib import Path
2
+ from create.agent import _write_llm_clients
3
+
4
+ def add_clients_to_existing_agent(
5
+ agent_dir: Path,
6
+ *,
7
+ clients: list[str],
8
+ force: bool = False,
9
+ ) -> list[Path]:
10
+ llm_clients_dir = agent_dir / "src" / "llm_clients"
11
+ if not llm_clients_dir.is_dir():
12
+ raise FileNotFoundError(
13
+ f"Directory '{llm_clients_dir}' not found. Run this command from an agent root containing src/llm_clients."
14
+ )
15
+
16
+ return _write_llm_clients(llm_clients_dir, clients=clients, force=force)