evoloop-cli 0.1.0__py3-none-any.whl

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 (103) hide show
  1. evoloop_cli/__init__.py +3 -0
  2. evoloop_cli/__main__.py +10 -0
  3. evoloop_cli/_skills/evoloop-constitution/SKILL.md +59 -0
  4. evoloop_cli/_skills/evoloop-constitution/references/writing-guide.md +89 -0
  5. evoloop_cli/_skills/evoloop-constitution/templates/config.yaml +52 -0
  6. evoloop_cli/_skills/evoloop-constitution/templates/constitution.md +39 -0
  7. evoloop_cli/_skills/evoloop-evaluate/SKILL.md +85 -0
  8. evoloop_cli/_skills/evoloop-evaluate/schemas/parsed_report.schema.json +170 -0
  9. evoloop_cli/_skills/evoloop-evaluate/scripts/parse_junit_report.py +311 -0
  10. evoloop_cli/_skills/evoloop-evaluate/scripts/parse_pytest_report.py +276 -0
  11. evoloop_cli/_skills/evoloop-evaluate/scripts/parse_report.py +101 -0
  12. evoloop_cli/_skills/evoloop-evaluate/scripts/update_eval_index.py +111 -0
  13. evoloop_cli/_skills/evoloop-evaluate/scripts/validate_parsed_report.py +178 -0
  14. evoloop_cli/_skills/evoloop-evaluate/templates/analysis.md +51 -0
  15. evoloop_cli/_skills/evoloop-evaluate/templates/progress.md +42 -0
  16. evoloop_cli/_skills/evoloop-evaluate/templates/tasks.md +34 -0
  17. evoloop_cli/_skills/evoloop-evolve/SKILL.md +76 -0
  18. evoloop_cli/_skills/evoloop-evolve/scripts/evolve_state.py +333 -0
  19. evoloop_cli/_skills/evoloop-implement/SKILL.md +57 -0
  20. evoloop_cli/_skills/evoloop-implement/scripts/check_scope.py +154 -0
  21. evoloop_cli/_skills/evoloop-implement/scripts/commit_section.py +78 -0
  22. evoloop_cli/_skills/evoloop-init/SKILL.md +95 -0
  23. evoloop_cli/_skills/evoloop-init/scripts/scaffold_evals.py +546 -0
  24. evoloop_cli/_skills/evoloop-init/templates/common/evals/datasets/domain_flows.yaml +33 -0
  25. evoloop_cli/_skills/evoloop-init/templates/common/evaluations/README.md +9 -0
  26. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/AgentAdapter.java +13 -0
  27. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java +71 -0
  28. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/DeterministicEvaluators.java +174 -0
  29. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java +45 -0
  30. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/FlowRunResult.java +25 -0
  31. evoloop_cli/_skills/evoloop-init/templates/python/evals/__init__.py +1 -0
  32. evoloop_cli/_skills/evoloop-init/templates/python/evals/adapter.py +63 -0
  33. evoloop_cli/_skills/evoloop-init/templates/python/evals/deepagents_adapter.py +223 -0
  34. evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/__init__.py +1 -0
  35. evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/deterministic.py +234 -0
  36. evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/llm_judge.py +189 -0
  37. evoloop_cli/_skills/evoloop-init/templates/python/evals/fakes.py +26 -0
  38. evoloop_cli/_skills/evoloop-init/templates/python/evals/harness.py +100 -0
  39. evoloop_cli/_skills/evoloop-init/templates/python/tests/conftest.py +38 -0
  40. evoloop_cli/_skills/evoloop-init/templates/python/tests/test_agentic_flows.py +36 -0
  41. evoloop_cli/_skills/evoloop-init/templates/python/tests/test_eval_framework.py +175 -0
  42. evoloop_cli/_skills/evoloop-new/SKILL.md +125 -0
  43. evoloop_cli/_skills/evoloop-new/scripts/scaffold_agent.py +911 -0
  44. evoloop_cli/_skills/evoloop-new/templates/common/.evoloop/constitution.md +34 -0
  45. evoloop_cli/_skills/evoloop-new/templates/common/.gitignore +22 -0
  46. evoloop_cli/_skills/evoloop-new/templates/common/AGENTS.md +17 -0
  47. evoloop_cli/_skills/evoloop-new/templates/common/README.md +83 -0
  48. evoloop_cli/_skills/evoloop-new/templates/common/skills/__DOMAIN__/SKILL.md +21 -0
  49. evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java +113 -0
  50. evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java +85 -0
  51. evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/Fake__DOMAIN_PASCAL__Client.java +37 -0
  52. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/Application.java +46 -0
  53. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/OpenAiCompatibleRunner.java +433 -0
  54. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +125 -0
  55. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/Application.java +46 -0
  56. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +163 -0
  57. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +18 -0
  58. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/Application.java +15 -0
  59. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +167 -0
  60. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Controller.java +41 -0
  61. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Factory.java +32 -0
  62. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +20 -0
  63. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/resources/application.yml +17 -0
  64. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/Application.java +17 -0
  65. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +159 -0
  66. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Config.java +32 -0
  67. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Controller.java +40 -0
  68. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +25 -0
  69. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/resources/application.yml +19 -0
  70. evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_custom.gradle +33 -0
  71. evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_langchain4j.gradle +40 -0
  72. evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_micronaut.gradle +52 -0
  73. evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_spring-ai.gradle +45 -0
  74. evoloop_cli/_skills/evoloop-new/templates/java/gradle/settings.gradle +1 -0
  75. evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_custom.xml +57 -0
  76. evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_langchain4j.xml +87 -0
  77. evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_micronaut.xml +101 -0
  78. evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_spring-ai.xml +61 -0
  79. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/ConversationMemory.java +36 -0
  80. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/Default__DOMAIN_PASCAL__Client.java +9 -0
  81. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/DomainRecord.java +10 -0
  82. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/TurnOutcome.java +15 -0
  83. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Client.java +8 -0
  84. evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/fakes.py +22 -0
  85. evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/harness_custom.py +186 -0
  86. evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/harness_deepagents.py +100 -0
  87. evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/tests/test_eval_framework.py +196 -0
  88. evoloop_cli/_skills/evoloop-new/templates/python/pyproject.toml +18 -0
  89. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/__init__.py +13 -0
  90. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/__main__.py +6 -0
  91. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/agent_custom.py +209 -0
  92. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/agent_deepagents.py +61 -0
  93. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/cli.py +71 -0
  94. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/client.py +31 -0
  95. evoloop_cli/_skills/evoloop-scenarios/SKILL.md +49 -0
  96. evoloop_cli/_skills/evoloop-scenarios/scripts/validate_scenarios.py +261 -0
  97. evoloop_cli/_skills/evoloop-scenarios/templates/scenario_schema.md +49 -0
  98. evoloop_cli/cli.py +331 -0
  99. evoloop_cli-0.1.0.dist-info/METADATA +214 -0
  100. evoloop_cli-0.1.0.dist-info/RECORD +103 -0
  101. evoloop_cli-0.1.0.dist-info/WHEEL +4 -0
  102. evoloop_cli-0.1.0.dist-info/entry_points.txt +2 -0
  103. evoloop_cli-0.1.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,261 @@
1
+ #!/usr/bin/env -S uv run --script
2
+ # /// script
3
+ # requires-python = ">=3.11"
4
+ # dependencies = ["pyyaml>=6.0"]
5
+ # ///
6
+ """Validate an evoloop YAML scenario dataset against schema and best-practice rules."""
7
+
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import ast
12
+ import json
13
+ import re
14
+ import sys
15
+ from pathlib import Path
16
+ from typing import Any
17
+
18
+ import yaml
19
+
20
+ VALID_MATCH_MODES = frozenset({"strict", "unordered", "subset", "superset"})
21
+ ID_PATTERN = re.compile(r"^[a-z][a-z0-9_]*$")
22
+ MAX_GROUNDED_GROUP_SIZE_WARN = 4
23
+
24
+
25
+ def extract_domain_tools_from_harness(harness_path: Path) -> set[str] | None:
26
+ """Best-effort AST extraction of DOMAIN_TOOLS string literals from harness.py."""
27
+ if not harness_path.is_file():
28
+ return None
29
+ tree = ast.parse(harness_path.read_text(encoding="utf-8"))
30
+ for node in ast.walk(tree):
31
+ target_name = None
32
+ value_node = None
33
+ if isinstance(node, ast.Assign) and len(node.targets) == 1:
34
+ if isinstance(node.targets[0], ast.Name):
35
+ target_name = node.targets[0].id
36
+ value_node = node.value
37
+ elif isinstance(node, ast.AnnAssign) and isinstance(node.target, ast.Name):
38
+ target_name = node.target.id
39
+ value_node = node.value
40
+
41
+ if target_name == "DOMAIN_TOOLS" and value_node is not None:
42
+ tools = _extract_string_collection(value_node)
43
+ if tools is not None:
44
+ return tools
45
+ return None
46
+
47
+
48
+ def _extract_string_collection(node: ast.AST) -> set[str] | None:
49
+ if isinstance(node, (ast.Set, ast.List, ast.Tuple)):
50
+ if all(isinstance(e, ast.Constant) and isinstance(e.value, str) for e in node.elts):
51
+ return {e.value for e in node.elts} # type: ignore[union-attr]
52
+ if isinstance(node, ast.Call) and isinstance(node.func, ast.Name):
53
+ if node.func.id in ("frozenset", "set") and len(node.args) == 1:
54
+ return _extract_string_collection(node.args[0])
55
+ return None
56
+
57
+
58
+ def validate_dataset(
59
+ data: Any,
60
+ *,
61
+ domain_tools: set[str] | None = None,
62
+ ) -> tuple[list[str], list[str]]:
63
+ """Return (errors, warnings) for a parsed YAML scenario dataset."""
64
+ errors: list[str] = []
65
+ warnings: list[str] = []
66
+
67
+ if not isinstance(data, dict) or not isinstance(data.get("cases"), list):
68
+ return (["Top-level YAML must be a mapping containing a 'cases' list."], [])
69
+
70
+ cases = data["cases"]
71
+ if not cases:
72
+ return (["'cases' list must not be empty."], [])
73
+
74
+ seen_ids: set[str] = set()
75
+
76
+ for idx, case in enumerate(cases):
77
+ prefix = f"cases[{idx}]"
78
+ if not isinstance(case, dict):
79
+ errors.append(f"{prefix}: case must be a mapping.")
80
+ continue
81
+
82
+ case_id = case.get("id")
83
+ if not isinstance(case_id, str) or not case_id.strip():
84
+ errors.append(f"{prefix}: missing non-empty string 'id'.")
85
+ label = prefix
86
+ else:
87
+ label = f"case '{case_id}'"
88
+ if case_id in seen_ids:
89
+ errors.append(f"{label}: duplicate case id.")
90
+ seen_ids.add(case_id)
91
+ if not ID_PATTERN.match(case_id):
92
+ warnings.append(f"{label}: id should be lowercase snake_case.")
93
+
94
+ for req_str in ("description", "category", "rubric_criteria"):
95
+ val = case.get(req_str)
96
+ if not isinstance(val, str) or not val.strip():
97
+ errors.append(f"{label}: missing non-empty string '{req_str}'.")
98
+
99
+ turns = case.get("turns")
100
+ if not isinstance(turns, list) or not turns or not all(
101
+ isinstance(t, str) and t.strip() for t in turns
102
+ ):
103
+ errors.append(f"{label}: 'turns' must be a non-empty list of non-empty strings.")
104
+ num_turns = 0
105
+ else:
106
+ num_turns = len(turns)
107
+
108
+ mode = case.get("trajectory_match_mode")
109
+ if mode not in VALID_MATCH_MODES:
110
+ errors.append(
111
+ f"{label}: 'trajectory_match_mode' must be one of {sorted(VALID_MATCH_MODES)}, got {mode!r}."
112
+ )
113
+
114
+ expected = case.get("expected_tool_calls")
115
+ if not isinstance(expected, list):
116
+ errors.append(f"{label}: 'expected_tool_calls' must be a list (may be empty).")
117
+ expected_count = 0
118
+ else:
119
+ expected_count = len(expected)
120
+ for tc_idx, tc in enumerate(expected):
121
+ if not isinstance(tc, dict) or not isinstance(tc.get("name"), str) or not tc["name"]:
122
+ errors.append(f"{label}: expected_tool_calls[{tc_idx}] must have a string 'name'.")
123
+ continue
124
+ if "args" in tc and not isinstance(tc["args"], dict):
125
+ errors.append(f"{label}: expected_tool_calls[{tc_idx}].args must be a mapping.")
126
+ if domain_tools is not None and tc["name"] not in domain_tools:
127
+ errors.append(
128
+ f"{label}: expected tool '{tc['name']}' is not in DOMAIN_TOOLS {sorted(domain_tools)}."
129
+ )
130
+
131
+ max_calls = case.get("max_tool_calls")
132
+ if not isinstance(max_calls, int) or isinstance(max_calls, bool) or max_calls < 0:
133
+ errors.append(f"{label}: 'max_tool_calls' must be a non-negative integer.")
134
+ elif expected_count > max_calls:
135
+ warnings.append(
136
+ f"{label}: expected_tool_calls ({expected_count}) exceeds max_tool_calls ({max_calls})."
137
+ )
138
+
139
+ forbidden_tools = case.get("forbidden_tools")
140
+ if forbidden_tools is not None:
141
+ if not isinstance(forbidden_tools, list) or not all(isinstance(t, str) for t in forbidden_tools):
142
+ errors.append(f"{label}: 'forbidden_tools' must be a list of tool name strings.")
143
+ elif domain_tools is not None:
144
+ for t in forbidden_tools:
145
+ if t not in domain_tools:
146
+ errors.append(
147
+ f"{label}: forbidden tool '{t}' is not in DOMAIN_TOOLS {sorted(domain_tools)}."
148
+ )
149
+
150
+ turn_assertions = case.get("turn_assertions")
151
+ if num_turns > 1 and not turn_assertions:
152
+ warnings.append(
153
+ f"{label}: multi-turn case ({num_turns} turns) has no 'turn_assertions'."
154
+ )
155
+ if turn_assertions is not None:
156
+ if not isinstance(turn_assertions, list):
157
+ errors.append(f"{label}: 'turn_assertions' must be a list.")
158
+ else:
159
+ for ta_idx, ta in enumerate(turn_assertions):
160
+ if not isinstance(ta, dict):
161
+ errors.append(f"{label}: turn_assertions[{ta_idx}] must be a mapping.")
162
+ continue
163
+ t_idx = ta.get("turn_index")
164
+ if not isinstance(t_idx, int) or isinstance(t_idx, bool) or not (0 <= t_idx < num_turns):
165
+ errors.append(
166
+ f"{label}: turn_assertions[{ta_idx}].turn_index={t_idx!r} out of range [0, {max(num_turns - 1, 0)}]."
167
+ )
168
+ for field_name in ("forbidden_tools", "required_tools"):
169
+ tlist = ta.get(field_name)
170
+ if tlist is not None:
171
+ if not isinstance(tlist, list) or not all(isinstance(t, str) for t in tlist):
172
+ errors.append(f"{label}: turn_assertions[{ta_idx}].{field_name} must be a list of strings.")
173
+ elif domain_tools is not None:
174
+ for t in tlist:
175
+ if t not in domain_tools:
176
+ errors.append(
177
+ f"{label}: turn_assertions[{ta_idx}].{field_name} references unknown tool '{t}'."
178
+ )
179
+
180
+ grounded = case.get("grounded_any_of")
181
+ if grounded is not None:
182
+ if not isinstance(grounded, list):
183
+ errors.append(f"{label}: 'grounded_any_of' must be a list of token lists.")
184
+ else:
185
+ for g_idx, group in enumerate(grounded):
186
+ if not isinstance(group, list) or not group or not all(
187
+ isinstance(tok, str) and tok for tok in group
188
+ ):
189
+ errors.append(
190
+ f"{label}: grounded_any_of[{g_idx}] must be a non-empty list of non-empty strings."
191
+ )
192
+ elif len(group) > MAX_GROUNDED_GROUP_SIZE_WARN:
193
+ warnings.append(
194
+ f"{label}: grounded_any_of[{g_idx}] has {len(group)} tokens {group!r}; "
195
+ "avoid brittle conversational synonym lists (keep factual tokens only and use rubric_criteria for phrasing)."
196
+ )
197
+
198
+ forbidden_substrings = case.get("forbidden_substrings")
199
+ if forbidden_substrings is not None:
200
+ if not isinstance(forbidden_substrings, list) or not all(
201
+ isinstance(s, str) and s for s in forbidden_substrings
202
+ ):
203
+ errors.append(f"{label}: 'forbidden_substrings' must be a list of non-empty strings.")
204
+
205
+ return errors, warnings
206
+
207
+
208
+ def main(argv: list[str] | None = None) -> int:
209
+ parser = argparse.ArgumentParser(description="Validate evoloop scenario YAML dataset.")
210
+ parser.add_argument("dataset", type=Path, help="Path to scenario YAML file.")
211
+ parser.add_argument("--harness", type=Path, default=None, help="Optional path to harness.py to check DOMAIN_TOOLS.")
212
+ parser.add_argument("--config", type=Path, default=None, help="Optional path to .evoloop/config.yaml.")
213
+ parser.add_argument("--strict-warnings", action="store_true", help="Exit non-zero on warnings as well as errors.")
214
+ parser.add_argument("--json", action="store_true", dest="as_json", help="Emit JSON output.")
215
+ args = parser.parse_args(argv)
216
+
217
+ if not args.dataset.is_file():
218
+ print(f"ERROR: Dataset file not found: {args.dataset}", file=sys.stderr)
219
+ return 2
220
+
221
+ harness_path = args.harness
222
+ if harness_path is None and args.config is not None and args.config.is_file():
223
+ cfg = yaml.safe_load(args.config.read_text(encoding="utf-8")) or {}
224
+ h_str = (cfg.get("paths") or {}).get("harness")
225
+ if h_str:
226
+ harness_path = Path(h_str)
227
+
228
+ domain_tools = extract_domain_tools_from_harness(harness_path) if harness_path else None
229
+ data = yaml.safe_load(args.dataset.read_text(encoding="utf-8"))
230
+ errors, warnings = validate_dataset(data, domain_tools=domain_tools)
231
+
232
+ if args.as_json:
233
+ print(
234
+ json.dumps(
235
+ {
236
+ "dataset": str(args.dataset),
237
+ "valid": len(errors) == 0 and (not args.strict_warnings or len(warnings) == 0),
238
+ "case_count": len(data.get("cases", [])) if isinstance(data, dict) else 0,
239
+ "domain_tools_checked": sorted(domain_tools) if domain_tools is not None else None,
240
+ "errors": errors,
241
+ "warnings": warnings,
242
+ },
243
+ indent=2,
244
+ )
245
+ )
246
+ else:
247
+ for w in warnings:
248
+ print(f"WARN: {w}")
249
+ for e in errors:
250
+ print(f"ERROR: {e}")
251
+ if not errors and not warnings:
252
+ count = len(data.get("cases", [])) if isinstance(data, dict) else 0
253
+ print(f"OK: {args.dataset} ({count} cases validated cleanly).")
254
+
255
+ if errors or (args.strict_warnings and warnings):
256
+ return 1
257
+ return 0
258
+
259
+
260
+ if __name__ == "__main__":
261
+ raise SystemExit(main())
@@ -0,0 +1,49 @@
1
+ # Evoloop Scenario YAML Schema
2
+
3
+ Store dataset files at `evals/datasets/<domain>_flows.yaml` with a top-level `cases:` list.
4
+
5
+ ## Top-Level Structure
6
+
7
+ ```yaml
8
+ cases:
9
+ - id: <unique_snake_case_id> # Required, unique across file
10
+ description: <short summary> # Required
11
+ category: <category_name> # Required (for example: happy_path, multi_turn, error_recovery, input_validation, edge_case, scope_adherence)
12
+ turns: # Required, non-empty list of user messages
13
+ - "User turn 1 message"
14
+ - "User turn 2 follow-up"
15
+ fake_client: # Optional fault-injection and fixture config
16
+ fail_mode: service_outage # Passed to build_fake_client(case)
17
+ expected_tool_calls: # Required (may be [] for zero-tool cases)
18
+ - name: <domain_tool_name>
19
+ args: { key: "value" }
20
+ trajectory_match_mode: unordered # Required: strict | unordered | subset | superset
21
+ forbidden_tools: # Optional list of tool names forbidden across all turns
22
+ - <domain_tool_name>
23
+ turn_assertions: # Recommended for all multi-turn cases (len(turns) > 1)
24
+ - turn_index: 0 # 0-based index into turns
25
+ forbidden_tools: [<tool>]
26
+ required_tools: [<tool>]
27
+ max_tool_calls: 4 # Required non-negative integer
28
+ allow_duplicate_calls: false # Optional (default false)
29
+ grounded_any_of: # Optional list of token groups (OR inside each group, AND across groups)
30
+ - ["42.00", "$42", "$42.00"] # Factual tokens only; avoid fragile prose synonym lists
31
+ - ["ORD-1001"]
32
+ forbidden_substrings: # Optional substrings that must not appear in the final response
33
+ - "EUR"
34
+ - "internal_tool_name"
35
+ rubric_criteria: > # Required clear, unambiguous rubric for LLM-as-a-Judge
36
+ Clear description of required trajectory and response quality.
37
+ ```
38
+
39
+ ## Validation Rules in `validate_scenarios.py`
40
+
41
+ `validate_scenarios.py` checks these rules:
42
+
43
+ - `cases` must be a non-empty list.
44
+ - Every case must define a unique `id`, `description`, `category`, non-empty `turns`, `expected_tool_calls`, `trajectory_match_mode` (`strict`, `unordered`, `subset`, or `superset`), integer `max_tool_calls >= 0`, and non-empty `rubric_criteria`.
45
+ - `turn_assertions[].turn_index` must be in `[0, len(turns) - 1]`.
46
+ - If `--harness` exposes `DOMAIN_TOOLS`, every tool in `expected_tool_calls`, `forbidden_tools`, and `turn_assertions` must exist in `DOMAIN_TOOLS`.
47
+ - The validator warns if a multi-turn case (`len(turns) > 1`) omits `turn_assertions`.
48
+ - The validator warns if any `grounded_any_of` group has more than 4 entries, because large groups often indicate fragile synonym lists.
49
+ - The validator warns if the length of `expected_tool_calls` exceeds `max_tool_calls`.
evoloop_cli/cli.py ADDED
@@ -0,0 +1,331 @@
1
+ #!/usr/bin/env python3
2
+ # /// script
3
+ # requires-python = ">=3.11"
4
+ # ///
5
+ """Minimalistic CLI to install or update Evoloop skills in `.agents/skills`."""
6
+
7
+ from __future__ import annotations
8
+
9
+ import argparse
10
+ import shutil
11
+ import sys
12
+ import tempfile
13
+ from dataclasses import dataclass
14
+ from pathlib import Path
15
+ from typing import Literal, Sequence
16
+
17
+ try:
18
+ from . import __version__
19
+ except ImportError:
20
+ __version__ = "0.1.0"
21
+
22
+ DEFAULT_SKILLS_SUBDIR = Path(".agents") / "skills"
23
+ IGNORED_DIR_NAMES = frozenset({"__pycache__", ".git", ".pytest_cache"})
24
+ IGNORED_FILE_NAMES = frozenset({".DS_Store"})
25
+ IGNORED_SUFFIXES = frozenset({".pyc", ".pyo", ".iml"})
26
+
27
+ SyncStatus = Literal["installed", "updated", "up-to-date"]
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ class SkillSyncResult:
32
+ name: str
33
+ status: SyncStatus
34
+ file_count: int
35
+
36
+
37
+ @dataclass(frozen=True)
38
+ class SyncReport:
39
+ source: Path
40
+ destination: Path
41
+ created_destination: bool
42
+ dry_run: bool
43
+ results: tuple[SkillSyncResult, ...]
44
+
45
+
46
+ def discover_skills(skills_source: Path) -> list[Path]:
47
+ """Return sorted skill directories under `skills_source` that contain `SKILL.md`."""
48
+ if not skills_source.is_dir():
49
+ raise FileNotFoundError(f"Skills source directory does not exist: {skills_source}")
50
+ return [
51
+ entry
52
+ for entry in sorted(skills_source.iterdir())
53
+ if entry.is_dir() and (entry / "SKILL.md").is_file()
54
+ ]
55
+
56
+
57
+ def resolve_skills_source(explicit_source: Path | None = None) -> Path:
58
+ """Locate bundled skills inside the installed package or the local repository."""
59
+ if explicit_source is not None:
60
+ source = explicit_source.expanduser().resolve()
61
+ if not source.is_dir():
62
+ raise FileNotFoundError(f"Skills source directory does not exist: {source}")
63
+ return source
64
+
65
+ module_dir = Path(__file__).resolve().parent
66
+ bundled_skills = module_dir / "_skills"
67
+ if bundled_skills.is_dir() and discover_skills(bundled_skills):
68
+ return bundled_skills
69
+
70
+ for parent in module_dir.parents:
71
+ candidate = parent / DEFAULT_SKILLS_SUBDIR
72
+ if candidate.is_dir() and discover_skills(candidate):
73
+ return candidate
74
+
75
+ raise FileNotFoundError(
76
+ "Could not locate bundled Evoloop skills. "
77
+ "Reinstall evoloop-cli or pass --source <path-to-.agents/skills>."
78
+ )
79
+
80
+
81
+ def _is_ignored(rel_parts: tuple[str, ...], file_path: Path) -> bool:
82
+ if any(part in IGNORED_DIR_NAMES for part in rel_parts[:-1]):
83
+ return True
84
+ return file_path.name in IGNORED_FILE_NAMES or file_path.suffix in IGNORED_SUFFIXES
85
+
86
+
87
+ def collect_skill_files(skill_dir: Path) -> dict[str, Path]:
88
+ """Return relative POSIX paths to non-ignored files within `skill_dir`."""
89
+ files: dict[str, Path] = {}
90
+ for path in sorted(skill_dir.rglob("*")):
91
+ if not path.is_file():
92
+ continue
93
+ rel = path.relative_to(skill_dir)
94
+ if _is_ignored(rel.parts, path):
95
+ continue
96
+ files[rel.as_posix()] = path
97
+ return files
98
+
99
+
100
+ def _is_skill_up_to_date(src_files: dict[str, Path], dst_dir: Path) -> bool:
101
+ if not dst_dir.is_dir():
102
+ return False
103
+ dst_files = collect_skill_files(dst_dir)
104
+ if set(src_files.keys()) != set(dst_files.keys()):
105
+ return False
106
+ for rel_path, src_file in src_files.items():
107
+ if src_file.read_bytes() != dst_files[rel_path].read_bytes():
108
+ return False
109
+ return True
110
+
111
+
112
+ def _write_skill_dir(src_files: dict[str, Path], dst_dir: Path) -> None:
113
+ """Write `src_files` into `dst_dir` cleanly via a staging sibling directory."""
114
+ staging_parent = dst_dir.parent
115
+ staging_dir = Path(tempfile.mkdtemp(prefix=f".{dst_dir.name}.tmp-", dir=staging_parent))
116
+ try:
117
+ for rel_path, src_file in src_files.items():
118
+ out_file = staging_dir / rel_path
119
+ out_file.parent.mkdir(parents=True, exist_ok=True)
120
+ shutil.copy2(src_file, out_file)
121
+
122
+ if dst_dir.exists():
123
+ shutil.rmtree(dst_dir)
124
+ staging_dir.rename(dst_dir)
125
+ except Exception:
126
+ if staging_dir.exists():
127
+ shutil.rmtree(staging_dir, ignore_errors=True)
128
+ raise
129
+
130
+
131
+ def sync_skills(
132
+ target_dir: Path,
133
+ *,
134
+ skills_dir: Path = DEFAULT_SKILLS_SUBDIR,
135
+ source_dir: Path | None = None,
136
+ dry_run: bool = False,
137
+ ) -> SyncReport:
138
+ """Create `.agents/skills` if needed and copy or update every Evoloop skill."""
139
+ resolved_source = resolve_skills_source(source_dir)
140
+ skills = discover_skills(resolved_source)
141
+ if not skills:
142
+ raise FileNotFoundError(f"No skills with SKILL.md found in {resolved_source}")
143
+
144
+ dest_skills_dir = (
145
+ skills_dir.expanduser().resolve()
146
+ if skills_dir.is_absolute()
147
+ else (target_dir.expanduser().resolve() / skills_dir).resolve()
148
+ )
149
+
150
+ if resolved_source == dest_skills_dir:
151
+ raise ValueError(
152
+ f"Source and destination skills directories are the same: {dest_skills_dir}"
153
+ )
154
+
155
+ created_destination = not dest_skills_dir.exists()
156
+ if not dry_run:
157
+ dest_skills_dir.mkdir(parents=True, exist_ok=True)
158
+
159
+ results: list[SkillSyncResult] = []
160
+ for skill_src in skills:
161
+ src_files = collect_skill_files(skill_src)
162
+ skill_dst = dest_skills_dir / skill_src.name
163
+
164
+ if not skill_dst.exists():
165
+ status: SyncStatus = "installed"
166
+ if not dry_run:
167
+ _write_skill_dir(src_files, skill_dst)
168
+ elif _is_skill_up_to_date(src_files, skill_dst):
169
+ status = "up-to-date"
170
+ else:
171
+ status = "updated"
172
+ if not dry_run:
173
+ _write_skill_dir(src_files, skill_dst)
174
+
175
+ results.append(
176
+ SkillSyncResult(name=skill_src.name, status=status, file_count=len(src_files))
177
+ )
178
+
179
+ return SyncReport(
180
+ source=resolved_source,
181
+ destination=dest_skills_dir,
182
+ created_destination=created_destination,
183
+ dry_run=dry_run,
184
+ results=tuple(results),
185
+ )
186
+
187
+
188
+ def _add_sync_arguments(parser: argparse.ArgumentParser) -> None:
189
+ parser.add_argument(
190
+ "target",
191
+ nargs="?",
192
+ default=None,
193
+ help="Target project directory (default: current directory).",
194
+ )
195
+ parser.add_argument(
196
+ "--here",
197
+ action="store_true",
198
+ help="Install or update skills in the current directory.",
199
+ )
200
+ parser.add_argument(
201
+ "--skills-dir",
202
+ type=Path,
203
+ default=DEFAULT_SKILLS_SUBDIR,
204
+ help="Destination skills directory, relative to target or absolute (default: .agents/skills).",
205
+ )
206
+ parser.add_argument(
207
+ "--source",
208
+ type=Path,
209
+ default=None,
210
+ help="Optional custom source directory containing skill folders.",
211
+ )
212
+ parser.add_argument(
213
+ "--dry-run",
214
+ action="store_true",
215
+ help="Preview skill changes without writing files.",
216
+ )
217
+
218
+
219
+ def build_parser() -> argparse.ArgumentParser:
220
+ parser = argparse.ArgumentParser(
221
+ prog="evoloop",
222
+ description="Bootstrap and update Evoloop skills in .agents/skills.",
223
+ )
224
+ parser.add_argument(
225
+ "--version",
226
+ action="version",
227
+ version=f"evoloop-cli {__version__}",
228
+ )
229
+
230
+ subparsers = parser.add_subparsers(dest="command")
231
+
232
+ init_parser = subparsers.add_parser(
233
+ "init",
234
+ help="Create .agents/skills if needed and install or update every Evoloop skill.",
235
+ )
236
+ _add_sync_arguments(init_parser)
237
+
238
+ update_parser = subparsers.add_parser(
239
+ "update",
240
+ help="Update every Evoloop skill in .agents/skills (alias of init).",
241
+ )
242
+ _add_sync_arguments(update_parser)
243
+
244
+ list_parser = subparsers.add_parser(
245
+ "list",
246
+ help="List bundled Evoloop skills.",
247
+ )
248
+ list_parser.add_argument(
249
+ "--source",
250
+ type=Path,
251
+ default=None,
252
+ help="Optional custom source directory containing skill folders.",
253
+ )
254
+
255
+ subparsers.add_parser("version", help="Print the installed evoloop-cli version.")
256
+ return parser
257
+
258
+
259
+ def _print_sync_report(report: SyncReport) -> None:
260
+ prefix = "[dry-run] " if report.dry_run else ""
261
+ if report.created_destination:
262
+ action = "Would create" if report.dry_run else "Created"
263
+ print(f"{prefix}{action} {report.destination}")
264
+
265
+ for item in report.results:
266
+ label = item.status.upper().ljust(10)
267
+ print(f"{prefix} {label} {item.name} ({item.file_count} files)")
268
+
269
+ installed = sum(1 for item in report.results if item.status == "installed")
270
+ updated = sum(1 for item in report.results if item.status == "updated")
271
+ up_to_date = sum(1 for item in report.results if item.status == "up-to-date")
272
+
273
+ print(
274
+ f"{prefix}Synced {len(report.results)} skills in {report.destination} "
275
+ f"({installed} installed, {updated} updated, {up_to_date} up-to-date)."
276
+ )
277
+ if not report.dry_run and (installed > 0 or updated > 0):
278
+ print(
279
+ "Next step: run evoloop-new in an empty directory, "
280
+ "or evoloop-constitution in an existing repository."
281
+ )
282
+
283
+
284
+ def main(argv: Sequence[str] | None = None) -> int:
285
+ parser = build_parser()
286
+ args = parser.parse_args(argv)
287
+
288
+ if args.command is None:
289
+ parser.print_help()
290
+ return 0
291
+
292
+ if args.command == "version":
293
+ print(f"evoloop-cli {__version__}")
294
+ return 0
295
+
296
+ if args.command == "list":
297
+ try:
298
+ source = resolve_skills_source(args.source)
299
+ skills = discover_skills(source)
300
+ except FileNotFoundError as exc:
301
+ print(f"Error: {exc}", file=sys.stderr)
302
+ return 1
303
+ for skill_dir in skills:
304
+ print(skill_dir.name)
305
+ return 0
306
+
307
+ if args.command in ("init", "update"):
308
+ if args.here and args.target is not None:
309
+ print("Error: pass either a target directory or --here, not both.", file=sys.stderr)
310
+ return 2
311
+ target_dir = Path(".") if (args.here or args.target is None) else Path(args.target)
312
+ try:
313
+ report = sync_skills(
314
+ target_dir,
315
+ skills_dir=args.skills_dir,
316
+ source_dir=args.source,
317
+ dry_run=args.dry_run,
318
+ )
319
+ except (FileNotFoundError, ValueError) as exc:
320
+ print(f"Error: {exc}", file=sys.stderr)
321
+ return 1
322
+
323
+ _print_sync_report(report)
324
+ return 0
325
+
326
+ parser.print_help()
327
+ return 0
328
+
329
+
330
+ if __name__ == "__main__":
331
+ sys.exit(main())