Skip to content

Commit 070a23e

Browse files
authored
feat: refactor CLI to Agent-Native (MigoXLab#366)
1 parent b74f8b9 commit 070a23e

File tree

12 files changed

+218
-40
lines changed

12 files changed

+218
-40
lines changed

.cursor/rules/project-architecture.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ alwaysApply: true
1616
4. **Evaluator contract**: Every evaluator `eval()` method must return `EvalDetail` with `metric`, `status` (bool), `label` (list), and `reason` (list).
1717
5. **Dependencies**: Core deps in `requirements/runtime.txt`, optional in `requirements/datasource.txt`. New optional deps → add to `setup.py` extras_require.
1818
6. **MCP Server**: Entry point is `mcp_server.py`, uses FastMCP + SSE. Environment variables for LLM config (`OPENAI_API_KEY`, etc.).
19-
7. **Three interfaces**: SDK (Python API), CLI (`python -m dingo.run.cli`), MCP Server. All share the same `InputArgs` → `Executor` pipeline.
19+
7. **Three interfaces**: SDK (Python API), CLI (`dingo eval`), MCP Server. All share the same `InputArgs` → `Executor` pipeline.
2020
8. **Testing**: `pytest test/scripts --ignore=test/scripts/data`. Integration tests via CLI with configs in `.github/env/`.

.github/workflows/IntegrationTest.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,32 @@ jobs:
3636
3737
- name: Integration Test(local plaintext)
3838
run: |
39-
python -m dingo.run.cli --input .github/env/local_plaintext.json
40-
python -m dingo.run.cli --input .github/env/local_plaintext_save.json
39+
dingo eval --input .github/env/local_plaintext.json
40+
dingo eval --input .github/env/local_plaintext_save.json
4141
- name: Integration Test(local json)
4242
run: |
43-
python -m dingo.run.cli --input .github/env/local_json.json
43+
dingo eval --input .github/env/local_json.json
4444
- name: Integration Test(local jsonl)
4545
run: |
46-
python -m dingo.run.cli --input .github/env/local_jsonl.json
46+
dingo eval --input .github/env/local_jsonl.json
4747
- name: Integration Test(local listjson)
4848
run: |
49-
python -m dingo.run.cli --input .github/env/local_listjson.json
49+
dingo eval --input .github/env/local_listjson.json
5050
- name: Integration Test(huggingface plaintext)
5151
run: |
52-
python -m dingo.run.cli --input .github/env/hf_plaintext.json
52+
dingo eval --input .github/env/hf_plaintext.json
5353
- name: Integration Test(huggingface json)
5454
run: |
55-
python -m dingo.run.cli --input .github/env/hf_json.json
55+
dingo eval --input .github/env/hf_json.json
5656
- name: Integration Test(huggingface jsonl)
5757
run: |
58-
python -m dingo.run.cli --input .github/env/hf_jsonl.json
58+
dingo eval --input .github/env/hf_jsonl.json
5959
- name: Integration Test(huggingface listjson)
6060
run: |
61-
python -m dingo.run.cli --input .github/env/hf_listjson.json
61+
dingo eval --input .github/env/hf_listjson.json
6262
- name: Integration Test(custom config)
6363
run: |
64-
python -m dingo.run.cli --input .github/env/custom_config_rule.json
64+
dingo eval --input .github/env/custom_config_rule.json
6565
- name: Run unit tests
6666
run: |
6767
pytest test/scripts --ignore=test/scripts/data

AGENTS.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,20 @@ dingo/
3434
│ ├── optional.txt ← heavy optional deps (torch, pyspark, etc.)
3535
│ └── agent.txt ← agent evaluation deps (langchain, tavily)
3636
37+
├── SKILL.md ← AI agent skill definition (symlink → clawhub/SKILL.md)
3738
├── dingo/ ← core Python package
3839
│ ├── config/
3940
│ │ └── input_args.py ← InputArgs, EvalPiplineConfig, EvaluatorGroupConfig
4041
│ ├── io/
4142
│ │ ├── input/data.py ← Data model (Pydantic, extra="allow")
42-
│ │ └── output/ ← ResultInfo, EvalDetail, SummaryModel
43+
│ │ └── output/ ← ResultInfo, EvalDetail, SummaryModel (+ cross-layer analysis)
4344
│ ├── data/
4445
│ │ ├── datasource/ ← LocalDataSource, SQLDataSource, S3DataSource, HFDataSource
4546
│ │ ├── dataset/ ← Dataset implementations per source
4647
│ │ └── converter/ ← Format converters (JSON, JSONL, CSV, Parquet, etc.)
4748
│ ├── model/
4849
│ │ ├── model.py ← Model registry (rule_register, llm_register)
49-
│ │ ├── rule/ ← Rule-based evaluators (30+ built-in)
50+
│ │ ├── rule/ ← Rule-based evaluators (80+ built-in)
5051
│ │ │ ├── base.py ← BaseRule
5152
│ │ │ ├── rule_common.py ← Common rules (text quality, format, PII, etc.)
5253
│ │ │ └── utils/ ← Shared utilities (normalize, ngrams, etc.)
@@ -62,10 +63,10 @@ dingo/
6263
│ │ ├── agent_fact_check.py
6364
│ │ └── agent_hallucination.py
6465
│ ├── exec/
65-
│ │ ├── local.py ← LocalExecutor (single machine)
66+
│ │ ├── local.py ← LocalExecutor (single machine, cross-layer conflict detection)
6667
│ │ └── spark.py ← SparkExecutor (distributed)
6768
│ └── run/
68-
│ ├── cli.py ← CLI entry point
69+
│ ├── cli.py ← CLI entry point (subcommands: eval, info)
6970
│ └── vsl.py ← GUI visualization entry point
7071
7172
├── app/ ← React frontend (Next.js-style)
@@ -191,7 +192,7 @@ pip install "dingo-python[all]" # + Everything
191192
2. Create dataset class in `dingo/data/dataset/`
192193
3. Register in the respective `__init__.py`
193194
4. Use lazy imports if new dependencies required
194-
5. Add dependency to `requirements/datasource.txt` and `setup.py` extras
195+
5. Add dependency to `requirements/runtime.txt` (core) or `setup.py` extras (heavy/optional)
195196

196197
### Testing
197198

@@ -203,9 +204,32 @@ pytest test/scripts --ignore=test/scripts/data
203204
pytest test/scripts/model/llm/test_rag.py -v
204205

205206
# Integration tests (CLI)
206-
python -m dingo.run.cli --input test/env/local_plaintext.json
207+
dingo eval --input .github/env/local_plaintext.json
208+
dingo eval --input .github/env/local_json.json --json
207209
```
208210

211+
### CLI Reference
212+
213+
Dingo provides a `dingo` CLI command (installed via `pip install dingo-python`):
214+
215+
```bash
216+
# Run evaluation (primary command)
217+
dingo eval --input config.json # Human-readable output
218+
dingo eval --input config.json --json # JSON output (for agents/automation)
219+
220+
# List available evaluators, groups
221+
dingo info # Show all (rules, LLM, groups)
222+
dingo info --rules # Rule evaluators only
223+
dingo info --llm # LLM evaluators only
224+
dingo info --groups # Rule groups only
225+
dingo info --json # JSON output
226+
227+
# Backward compatibility (no subcommand)
228+
dingo --input config.json # Same as `dingo eval --input config.json`
229+
python -m dingo.run.cli --input config.json
230+
```
231+
232+
209233
### Version Conventions
210234

211235
- Version defined in `setup.py` (`version="2.0.0"`)
@@ -245,9 +269,10 @@ When these events occur, update the corresponding files:
245269
| Event | Update |
246270
|-------|--------|
247271
| New evaluator added | Ensure registration decorator is correct; update `docs/metrics.md` |
248-
| New datasource added | Update `requirements/datasource.txt`, `setup.py` extras, README install section |
249-
| New dependency added | Decide: `runtime.txt` (core) vs `datasource.txt` (optional); use lazy import for optional |
272+
| New datasource added | Update `requirements/runtime.txt`, `setup.py` extras if heavy, README install section |
273+
| New dependency added | Decide: `runtime.txt` (core) vs `setup.py` extras (heavy/optional); use lazy import for optional |
250274
| New MCP tool added | Update MCP Tools table in this file |
275+
| New CLI subcommand added | Update CLI Reference section in this file |
251276
| Directory structure change | Update this file |
252277
| Version bump | Update `setup.py` version field |
253278

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ if __name__ == '__main__':
188188
### Evaluate with Rule Sets
189189

190190
```shell
191-
python -m dingo.run.cli --input .github/env/local_plaintext.json
191+
dingo eval --input .github/env/local_plaintext.json
192192
```
193193

194194
### Evaluate with LLM (e.g., GPT-4o)
195195

196196
```shell
197-
python -m dingo.run.cli --input .github/env/local_json.json
197+
dingo eval --input .github/env/local_json.json
198198
```
199199

200200
## GUI Visualization

README_ja.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ if __name__ == '__main__':
187187
### ルールセットでの評価
188188

189189
```shell
190-
python -m dingo.run.cli --input .github/env/local_plaintext.json
190+
dingo eval --input .github/env/local_plaintext.json
191191
```
192192

193193
### LLM(例:GPT-4o)での評価
194194

195195
```shell
196-
python -m dingo.run.cli --input .github/env/local_json.json
196+
dingo eval --input .github/env/local_json.json
197197
```
198198

199199
## GUI可視化

README_zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ if __name__ == '__main__':
188188
### 使用规则集评估
189189

190190
```shell
191-
python -m dingo.run.cli --input .github/env/local_plaintext.json
191+
dingo eval --input .github/env/local_plaintext.json
192192
```
193193

194194
### 使用LLM评估(例如GPT-4o)
195195

196196
```shell
197-
python -m dingo.run.cli --input .github/env/local_json.json
197+
dingo eval --input .github/env/local_json.json
198198
```
199199

200200
## 图形界面可视化

SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
clawhub/SKILL.md

clawhub/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ python -c "from dingo.config import InputArgs; print('Dingo OK')"
4848
Dingo CLI takes a JSON config file as input:
4949

5050
```bash
51-
python -m dingo.run.cli --input config.json
51+
dingo eval --input config.json
5252
```
5353

5454
### Minimal rule-based config
@@ -293,7 +293,7 @@ outputs/<timestamp>/
293293
When using this skill on behalf of the user:
294294

295295
* **Always write a config file** before running CLI evaluation. Don't try to pass complex JSON inline.
296-
* **Quote file paths** with spaces in commands: `python -m dingo.run.cli --input "my config.json"`
296+
* **Quote file paths** with spaces in commands: `dingo eval --input "my config.json"`
297297
* **Wrap main code in `if __name__ == '__main__':`** when writing Python scripts — Dingo uses multiprocessing internally, which fails on macOS without this guard.
298298
* **Infer format from extension**: `.jsonl``jsonl`, `.json``json`, `.csv``csv`, `.txt``plaintext`.
299299
* **Default to rule-based** when the user doesn't specify evaluation type — it's free, fast, and needs no API key.

0 commit comments

Comments
 (0)