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,95 @@
1
+ ---
2
+ name: evoloop-init
3
+ description: Adopt evoloop in an existing agent repository (brownfield) without overwriting runtime code. Inspects the repository, persists the detected/selected stack (`python` or `java`) in `.evoloop/config.yaml`, and scaffolds only the native evaluation harness, adapter stubs, starter dataset, and `evaluations/README.md`. Use `evoloop-new` instead when starting from an empty folder.
4
+ ---
5
+
6
+ # Evoloop Init (Existing Agent / Brownfield)
7
+
8
+ Add a native `evoloop` evaluation harness to an **existing** agent repository without touching or overwriting existing runtime source files (`src/**`, `AGENTS.md`, `skills/**`).
9
+
10
+ > **Starting from an empty folder?** Use **`evoloop-new`** instead — it interactively scaffolds a complete, runnable, evaluation-ready agent project from scratch (runtime code, client interface, checkpointer, `AGENTS.md`, `SKILL.md`, `.evoloop/`, and wired evaluation harness).
11
+
12
+ Supported built-in stacks:
13
+ - **`python`** (`uv` + `pytest`, `AgentAdapter` with built-in `DeepAgentsAdapter`, `agentevals` + `arize-phoenix-evals`, `report_format: pytest`)
14
+ - **`java`** (`maven` or `gradle` + JUnit 5, `AgentAdapter`, native `DeterministicEvaluators`, `AgenticFlowEvalTest`, `report_format: junit-xml`)
15
+
16
+ ## Non-Destructive Brownfield Guarantee
17
+
18
+ `evoloop-init` **never creates or modifies** existing agent implementation files (`src/<pkg>/**`, `src/main/**`, `AGENTS.md`, `skills/**`). It only:
19
+ 1. Inspects the repository (read-only) to detect stack, build tool, framework, package, and prompt file.
20
+ 2. Creates evaluation harness files (`evals/`, eval tests, `evaluations/README.md`) — skipping any file that already exists unless `--force` is passed.
21
+ 3. Appends `[dependency-groups].eval` and `[tool.pytest.ini_options]` to `pyproject.toml` (Python) if missing, without altering existing `[project]` dependencies.
22
+ 4. Persists `project.stack`, `project.build_tool`, `project.report_format`, `paths`, `commands`, and `governance` into `.evoloop/config.yaml`.
23
+
24
+ ## Writing Style Requirement
25
+
26
+ Before writing or customizing any human-targeted document or code comment, read [`../evoloop-constitution/references/writing-guide.md`](../evoloop-constitution/references/writing-guide.md) (`.agents/skills/evoloop-constitution/references/writing-guide.md`). Apply its Simplified Technical English rules to every generated or edited:
27
+ - Documentation file (`evaluations/README.md`, `.evoloop/config.yaml` comments, scenario YAML comments)
28
+ - Code comment, Python docstring, and Java Javadoc added while wiring `TODO(domain)` spots in `evals/`, `tests/`, or `src/test/java/**/evals/`
29
+
30
+ ## Workflow
31
+
32
+ ### Step 1: Inspect the Existing Repository (Read-Only)
33
+ Run the repository detector first:
34
+ ```bash
35
+ uv run .agents/skills/evoloop-init/scripts/scaffold_evals.py --target . --detect
36
+ ```
37
+
38
+ - If `has_manifest` is `false` and `is_empty_project` is `true`, **stop and recommend `evoloop-new`** for greenfield project creation.
39
+ - Review `.evoloop/config.yaml` (if `evoloop-constitution` was already run). If `.evoloop/constitution.md` does not exist yet, recommend running `evoloop-constitution` before or right after initialization.
40
+
41
+ ### Step 2: Confirm Detected Stack & Domain
42
+ Confirm the detected settings with the user (or ask only for missing fields):
43
+ - **Stack:** `python` or `java`
44
+ - **Build tool:** `uv` (Python) or `maven` / `gradle` (Java)
45
+ - **Framework:** `deepagents` or `custom` (Python); `custom`, `spring-ai`, `langchain4j`, or `micronaut` (Java)
46
+ - **Java base package** (if `java`, e.g., `com.example.agent`)
47
+ - **Domain name** (short `snake_case`, e.g., `billing`, `support`)
48
+
49
+ ### Step 3: Run the Brownfield Scaffolder
50
+ Run `scaffold_evals.py` (use `--dry-run` first to preview changes):
51
+
52
+ **Auto-detected stack (recommended for existing repos):**
53
+ ```bash
54
+ uv run .agents/skills/evoloop-init/scripts/scaffold_evals.py \
55
+ --target . \
56
+ --domain <domain_name>
57
+ ```
58
+
59
+ **Explicit Python (`uv` + `pytest`):**
60
+ ```bash
61
+ uv run .agents/skills/evoloop-init/scripts/scaffold_evals.py \
62
+ --target . \
63
+ --stack python \
64
+ --domain <domain_name> \
65
+ --framework deepagents
66
+ ```
67
+
68
+ **Explicit Java (`maven` or `gradle` + JUnit 5):**
69
+ ```bash
70
+ uv run .agents/skills/evoloop-init/scripts/scaffold_evals.py \
71
+ --target . \
72
+ --stack java \
73
+ --build-tool maven \
74
+ --java-package com.example.agent \
75
+ --domain <domain_name>
76
+ ```
77
+
78
+ ### Step 4: Wire Domain Adapters (Without Rewriting Runtime Architecture)
79
+ Customize only the clearly marked `TODO(domain)` spots:
80
+ - **Python:**
81
+ - `evals/fakes.py` — Deterministic fake client implementing your existing client interface/protocol with `fail_mode="service_outage"`.
82
+ - `evals/harness.py` — Set `DOMAIN_TOOLS`, wire `build_fake_client()` and `create_agent_for_eval()` (injecting your fake client and a checkpointer/state store for multi-turn state).
83
+ - `evals/evaluators/deterministic.py` — Optional `TOOL_ARG_MATCHERS` / `TOOL_ARG_NORMALIZERS`.
84
+ - `evals/evaluators/llm_judge.py` — Domain judge persona guidelines.
85
+ - **Java:**
86
+ - Ensure `org.junit.jupiter:junit-jupiter` and `org.yaml:snakeyaml` are in test dependencies (`pom.xml` / `build.gradle`).
87
+ - Wire `DOMAIN_TOOLS` and `createAdapter()` in `AgenticFlowEvalTest.java`.
88
+
89
+ ### Step 5: Verify Offline Gate
90
+ Run the configured offline test command from `.evoloop/config.yaml`:
91
+ - **Python:** `uv sync --group eval && uv run pytest`
92
+ - **Java (Maven):** `mvn test`
93
+ - **Java (Gradle):** `./gradlew test`
94
+
95
+ All offline unit tests MUST pass before proceeding to `evoloop-scenarios` or `evoloop-evaluate`.
@@ -0,0 +1,546 @@
1
+ #!/usr/bin/env -S uv run --script
2
+ # /// script
3
+ # requires-python = ">=3.11"
4
+ # dependencies = ["pyyaml>=6.0"]
5
+ # ///
6
+ """Scaffold the evoloop evaluation framework for a selected stack (python | java) and persist stack config."""
7
+
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import json
12
+ import re
13
+ import sys
14
+ import tomllib
15
+ from pathlib import Path
16
+ from typing import Any
17
+
18
+ import yaml
19
+
20
+ TEMPLATES_DIR = Path(__file__).resolve().parent.parent / "templates"
21
+
22
+ EVAL_DEPS = [
23
+ "agentevals>=0.0.9",
24
+ "arize-phoenix-evals>=3.10.0",
25
+ "openai>=1.0.0",
26
+ "pytest>=9.2.0",
27
+ "pytest-asyncio>=1.5.0",
28
+ "pyyaml>=6.0.3",
29
+ ]
30
+
31
+ STACK_DEFAULTS: dict[str, dict[str, Any]] = {
32
+ "python": {
33
+ "build_tool": "uv",
34
+ "framework": "deepagents",
35
+ "report_format": "pytest",
36
+ "paths": {
37
+ "harness": "evals/harness.py",
38
+ "fakes": "evals/fakes.py",
39
+ "offline_tests": "tests/test_eval_framework.py",
40
+ "live_tests": "tests/test_agentic_flows.py",
41
+ },
42
+ "commands": {
43
+ "offline_test": "uv run pytest",
44
+ "live_eval": "uv run pytest tests/test_agentic_flows.py --run-live-agent",
45
+ "live_eval_with_judge": "uv run pytest tests/test_agentic_flows.py --run-live-agent --run-judge",
46
+ },
47
+ "governance": {
48
+ "mutable_paths": [
49
+ "src/**",
50
+ "skills/**",
51
+ "AGENTS.md",
52
+ "evals/harness.py",
53
+ "evals/fakes.py",
54
+ "tests/test_eval_framework.py",
55
+ ],
56
+ "protected_paths": [
57
+ "evals/datasets/**",
58
+ "tests/test_agentic_flows.py",
59
+ ],
60
+ "evaluator_paths": [
61
+ "evals/evaluators/**",
62
+ ],
63
+ },
64
+ },
65
+ "java": {
66
+ "build_tool": "maven",
67
+ "framework": "custom",
68
+ "report_format": "junit-xml",
69
+ "paths": {
70
+ "harness": "src/test/java/__PACKAGE_PATH__/evals/AgentAdapter.java",
71
+ "offline_tests": "src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java",
72
+ "live_tests": "src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java",
73
+ "junit_reports_dir": "target/surefire-reports",
74
+ },
75
+ "commands": {
76
+ "offline_test": "mvn test",
77
+ "live_eval": "mvn test -Dtest=AgenticFlowEvalTest -DrunLiveAgent=true",
78
+ "live_eval_with_judge": "mvn test -Dtest=AgenticFlowEvalTest -DrunLiveAgent=true -DrunJudge=true",
79
+ },
80
+ "governance": {
81
+ "mutable_paths": [
82
+ "src/main/**",
83
+ "skills/**",
84
+ "AGENTS.md",
85
+ "src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java",
86
+ ],
87
+ "protected_paths": [
88
+ "evals/datasets/**",
89
+ "src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java",
90
+ ],
91
+ "evaluator_paths": [
92
+ "src/test/java/__PACKAGE_PATH__/evals/DeterministicEvaluators.java",
93
+ ],
94
+ },
95
+ },
96
+ }
97
+
98
+
99
+ def _find_java_package_and_agent(target: Path) -> tuple[str | None, str | None]:
100
+ java_root = target / "src" / "main" / "java"
101
+ if not java_root.is_dir():
102
+ return None, None
103
+
104
+ packages: list[str] = []
105
+ agent_file: str | None = None
106
+ first_java: str | None = None
107
+ for java_file in sorted(java_root.rglob("*.java")):
108
+ rel = str(java_file.relative_to(target)).replace("\\", "/")
109
+ if first_java is None:
110
+ first_java = rel
111
+ if agent_file is None and "agent" in java_file.stem.lower():
112
+ agent_file = rel
113
+ try:
114
+ text = java_file.read_text(encoding="utf-8", errors="ignore")
115
+ except OSError:
116
+ continue
117
+ match = re.search(r"^\s*package\s+([a-zA-Z0-9_.]+)\s*;", text, re.MULTILINE)
118
+ if match:
119
+ packages.append(match.group(1))
120
+
121
+ base_pkg = min(packages, key=lambda p: (p.count("."), len(p))) if packages else None
122
+ return base_pkg, agent_file or first_java
123
+
124
+
125
+ def _find_python_agent_file(target: Path) -> str | None:
126
+ search_roots = [target / "src"] if (target / "src").is_dir() else [target]
127
+ candidates: list[Path] = []
128
+ for root in search_roots:
129
+ for py_file in sorted(root.rglob("*.py")):
130
+ parts = py_file.relative_to(target).parts
131
+ if any(p.startswith(".") or p in {"evals", "tests", "__pycache__", ".venv"} for p in parts):
132
+ continue
133
+ if py_file.name == "__init__.py":
134
+ continue
135
+ if "agent" in py_file.stem.lower():
136
+ return str(py_file.relative_to(target)).replace("\\", "/")
137
+ candidates.append(py_file)
138
+ if candidates:
139
+ return str(candidates[0].relative_to(target)).replace("\\", "/")
140
+ return None
141
+
142
+
143
+ def detect_project(target: Path) -> dict[str, Any]:
144
+ """Inspect an existing repository (read-only) to infer stack, build tool, framework, and entry points."""
145
+ target = target.resolve()
146
+ info: dict[str, Any] = {
147
+ "target": str(target),
148
+ "has_manifest": False,
149
+ "manifest_file": None,
150
+ "is_empty_project": False,
151
+ "project_name": target.name,
152
+ "stack": None,
153
+ "build_tool": None,
154
+ "framework": None,
155
+ "java_package": None,
156
+ "system_prompt_file": None,
157
+ "has_agents_md": (target / "AGENTS.md").is_file(),
158
+ "has_skills_dir": (target / "skills").is_dir(),
159
+ "has_evoloop_config": (target / ".evoloop" / "config.yaml").is_file(),
160
+ "suggested_skill": "evoloop-init",
161
+ }
162
+
163
+ pyproject = target / "pyproject.toml"
164
+ pom_xml = target / "pom.xml"
165
+ gradle_groovy = target / "build.gradle"
166
+ gradle_kts = target / "build.gradle.kts"
167
+
168
+ if pyproject.is_file():
169
+ info["has_manifest"] = True
170
+ info["manifest_file"] = "pyproject.toml"
171
+ info["stack"] = "python"
172
+ info["build_tool"] = "uv"
173
+ raw = pyproject.read_text(encoding="utf-8", errors="ignore")
174
+ try:
175
+ data = tomllib.loads(raw)
176
+ except Exception:
177
+ data = {}
178
+ proj = data.get("project") or {}
179
+ if isinstance(proj.get("name"), str) and proj["name"].strip():
180
+ info["project_name"] = proj["name"].strip()
181
+ deps = [str(d).lower() for d in (proj.get("dependencies") or [])]
182
+ if any("deepagents" in d for d in deps) or "deepagents" in raw.lower():
183
+ info["framework"] = "deepagents"
184
+ else:
185
+ info["framework"] = "custom"
186
+ info["system_prompt_file"] = _find_python_agent_file(target)
187
+ return info
188
+
189
+ if pom_xml.is_file():
190
+ info["has_manifest"] = True
191
+ info["manifest_file"] = "pom.xml"
192
+ info["stack"] = "java"
193
+ info["build_tool"] = "maven"
194
+ raw = pom_xml.read_text(encoding="utf-8", errors="ignore")
195
+ artifact_match = re.search(r"<artifactId>\s*([^<\s]+)\s*</artifactId>", raw)
196
+ if artifact_match:
197
+ info["project_name"] = artifact_match.group(1)
198
+ lower = raw.lower()
199
+ if "micronaut" in lower:
200
+ info["framework"] = "micronaut"
201
+ elif "spring-ai" in lower:
202
+ info["framework"] = "spring-ai"
203
+ elif "langchain4j" in lower:
204
+ info["framework"] = "langchain4j"
205
+ else:
206
+ info["framework"] = "custom"
207
+ java_pkg, agent_file = _find_java_package_and_agent(target)
208
+ info["java_package"] = java_pkg
209
+ info["system_prompt_file"] = agent_file
210
+ return info
211
+
212
+ if gradle_groovy.is_file() or gradle_kts.is_file():
213
+ manifest = gradle_kts if gradle_kts.is_file() else gradle_groovy
214
+ info["has_manifest"] = True
215
+ info["manifest_file"] = manifest.name
216
+ info["stack"] = "java"
217
+ info["build_tool"] = "gradle"
218
+ raw = manifest.read_text(encoding="utf-8", errors="ignore")
219
+ for settings_name in ("settings.gradle.kts", "settings.gradle"):
220
+ settings_path = target / settings_name
221
+ if settings_path.is_file():
222
+ s_raw = settings_path.read_text(encoding="utf-8", errors="ignore")
223
+ m = re.search(r"""rootProject\.name\s*=\s*['"]([^'"]+)['"]""", s_raw)
224
+ if m:
225
+ info["project_name"] = m.group(1)
226
+ break
227
+ lower = raw.lower()
228
+ if "micronaut" in lower:
229
+ info["framework"] = "micronaut"
230
+ elif "spring-ai" in lower:
231
+ info["framework"] = "spring-ai"
232
+ elif "langchain4j" in lower:
233
+ info["framework"] = "langchain4j"
234
+ else:
235
+ info["framework"] = "custom"
236
+ java_pkg, agent_file = _find_java_package_and_agent(target)
237
+ info["java_package"] = java_pkg
238
+ info["system_prompt_file"] = agent_file
239
+ return info
240
+
241
+ # No recognized build manifest found
242
+ ignored_roots = {".git", ".agents", ".evoloop", ".DS_Store"}
243
+ meaningful = [p for p in target.iterdir() if p.name not in ignored_roots] if target.is_dir() else []
244
+ info["is_empty_project"] = len(meaningful) == 0
245
+ if info["is_empty_project"]:
246
+ info["suggested_skill"] = "evoloop-new"
247
+ return info
248
+
249
+
250
+ def _render_content(
251
+ text: str,
252
+ *,
253
+ domain: str,
254
+ framework: str,
255
+ java_package: str,
256
+ ) -> str:
257
+ pkg_path = java_package.replace(".", "/")
258
+ return (
259
+ text.replace("__DOMAIN__", domain)
260
+ .replace("__DOMAIN_TITLE__", domain.replace("_", " ").title())
261
+ .replace("__FRAMEWORK__", framework)
262
+ .replace("__JAVA_PACKAGE__", java_package)
263
+ .replace("__PACKAGE_PATH__", pkg_path)
264
+ )
265
+
266
+
267
+ def _update_pyproject(pyproject_path: Path, *, dry_run: bool) -> list[str]:
268
+ actions: list[str] = []
269
+ if not pyproject_path.is_file():
270
+ actions.append(f"SKIP: {pyproject_path} not found (create with `uv init` first).")
271
+ return actions
272
+
273
+ content = pyproject_path.read_text(encoding="utf-8")
274
+ updated = content
275
+
276
+ if "[dependency-groups]" not in updated:
277
+ dep_lines = "\n".join(f' "{dep}",' for dep in EVAL_DEPS)
278
+ updated = updated.rstrip() + f"\n\n[dependency-groups]\neval = [\n{dep_lines}\n]\n"
279
+ actions.append("UPDATE: Added [dependency-groups].eval to pyproject.toml")
280
+ elif "eval =" not in updated:
281
+ dep_lines = "\n".join(f' "{dep}",' for dep in EVAL_DEPS)
282
+ updated = updated.replace(
283
+ "[dependency-groups]",
284
+ f"[dependency-groups]\neval = [\n{dep_lines}\n]",
285
+ 1,
286
+ )
287
+ actions.append("UPDATE: Added eval group under [dependency-groups] in pyproject.toml")
288
+
289
+ if "[tool.pytest.ini_options]" not in updated:
290
+ py_paths = '["src", "."]' if (pyproject_path.parent / "src").is_dir() else '["."]'
291
+ updated = (
292
+ updated.rstrip()
293
+ + f'\n\n[tool.pytest.ini_options]\npythonpath = {py_paths}\ntestpaths = ["tests"]\n'
294
+ + 'asyncio_default_fixture_loop_scope = "function"\n'
295
+ )
296
+ actions.append("UPDATE: Added [tool.pytest.ini_options] to pyproject.toml")
297
+
298
+ if updated != content and not dry_run:
299
+ pyproject_path.write_text(updated, encoding="utf-8")
300
+
301
+ return actions
302
+
303
+
304
+ def _persist_stack_config(
305
+ target: Path,
306
+ *,
307
+ stack: str,
308
+ domain: str,
309
+ framework: str,
310
+ build_tool: str,
311
+ java_package: str,
312
+ project_name: str | None = None,
313
+ system_prompt_file: str | None = None,
314
+ dry_run: bool,
315
+ ) -> list[str]:
316
+ """Create or update .evoloop/config.yaml with the selected stack, commands, and paths."""
317
+ config_path = target / ".evoloop" / "config.yaml"
318
+ defaults = STACK_DEFAULTS[stack]
319
+ pkg_path = java_package.replace(".", "/")
320
+
321
+ def _sub(v: str) -> str:
322
+ return v.replace("__PACKAGE_PATH__", pkg_path).replace("__DOMAIN__", domain)
323
+
324
+ if config_path.is_file():
325
+ cfg = yaml.safe_load(config_path.read_text(encoding="utf-8")) or {}
326
+ else:
327
+ cfg = {
328
+ "version": 1,
329
+ "budgets": {"max_system_prompt_words": 120, "default_max_tool_calls": 4},
330
+ "evolve": {
331
+ "execution_mode": "subagent",
332
+ "max_iterations": 4,
333
+ "run_judge": True,
334
+ "require_approval_for_scenarios": True,
335
+ "require_approval_for_evaluators": True,
336
+ "stop_on_unrecovered_regression": True,
337
+ "max_file_edits_same_failure": 3,
338
+ "targeted_rerun_before_full": True,
339
+ },
340
+ }
341
+
342
+ project = dict(cfg.get("project") or {})
343
+ if project_name:
344
+ project["name"] = project_name
345
+ else:
346
+ project.setdefault("name", target.name)
347
+ project["stack"] = stack
348
+ project["build_tool"] = build_tool
349
+ project["framework"] = framework
350
+ project["domain"] = domain
351
+ project["report_format"] = defaults["report_format"]
352
+ if stack == "java":
353
+ project["java_package"] = java_package
354
+ cfg["project"] = project
355
+
356
+ paths = dict(cfg.get("paths") or {})
357
+ paths["dataset"] = f"evals/datasets/{domain}_flows.yaml"
358
+ paths.setdefault("evaluations_dir", "evaluations")
359
+ for k, v in defaults["paths"].items():
360
+ paths[k] = _sub(v)
361
+ if system_prompt_file:
362
+ paths["system_prompt_file"] = system_prompt_file
363
+ if stack == "java" and build_tool == "gradle":
364
+ paths["junit_reports_dir"] = "build/test-results/test"
365
+ cfg["paths"] = paths
366
+
367
+ commands = dict(defaults["commands"])
368
+ if stack == "java" and build_tool == "gradle":
369
+ commands = {
370
+ "offline_test": "./gradlew test",
371
+ "live_eval": "./gradlew test --tests '*AgenticFlowEvalTest' -DrunLiveAgent=true",
372
+ "live_eval_with_judge": "./gradlew test --tests '*AgenticFlowEvalTest' -DrunLiveAgent=true -DrunJudge=true",
373
+ }
374
+ cfg["commands"] = commands
375
+
376
+ gov = dict(cfg.get("governance") or {})
377
+ for k, v_list in defaults["governance"].items():
378
+ gov[k] = [_sub(item) for item in v_list]
379
+ cfg["governance"] = gov
380
+
381
+ if not dry_run:
382
+ config_path.parent.mkdir(parents=True, exist_ok=True)
383
+ config_path.write_text(yaml.safe_dump(cfg, sort_keys=False), encoding="utf-8")
384
+
385
+ verb = "WOULD PERSIST" if dry_run else "PERSIST"
386
+ return [f"{verb}: .evoloop/config.yaml (stack={stack}, build_tool={build_tool}, report_format={defaults['report_format']})"]
387
+
388
+
389
+ def scaffold_project(
390
+ target: Path,
391
+ *,
392
+ stack: str = "python",
393
+ domain: str = "domain",
394
+ framework: str | None = None,
395
+ build_tool: str | None = None,
396
+ java_package: str = "com.example.agent",
397
+ project_name: str | None = None,
398
+ system_prompt_file: str | None = None,
399
+ force: bool = False,
400
+ dry_run: bool = False,
401
+ ) -> list[str]:
402
+ """Copy common + stack-specific eval templates into an existing project and persist stack config."""
403
+ if stack not in STACK_DEFAULTS:
404
+ raise ValueError(f"Unsupported stack '{stack}'. Supported stacks: {sorted(STACK_DEFAULTS)}")
405
+
406
+ detected = detect_project(target)
407
+ resolved_framework = framework or STACK_DEFAULTS[stack]["framework"]
408
+ resolved_build_tool = build_tool or STACK_DEFAULTS[stack]["build_tool"]
409
+ resolved_project_name = project_name or (detected["project_name"] if detected["has_manifest"] else None)
410
+ resolved_prompt_file = system_prompt_file or detected["system_prompt_file"]
411
+ pkg_path = java_package.replace(".", "/")
412
+ actions: list[str] = []
413
+
414
+ if not detected["has_manifest"]:
415
+ actions.append(
416
+ "NOTE: No build manifest (pyproject.toml / pom.xml / build.gradle) found. "
417
+ "If creating a new agent from scratch, use the `evoloop-new` skill."
418
+ )
419
+
420
+ for subdir in ("common", stack):
421
+ src_root = TEMPLATES_DIR / subdir
422
+ if not src_root.is_dir():
423
+ continue
424
+ for src in sorted(src_root.rglob("*")):
425
+ if src.is_dir() or src.suffix in {".iml", ".pyc"} or src.name == ".DS_Store" or "__pycache__" in src.parts:
426
+ continue
427
+ rel = src.relative_to(src_root)
428
+ if rel.name == "domain_flows.yaml":
429
+ rel = rel.with_name(f"{domain}_flows.yaml")
430
+ if stack == "python" and resolved_framework != "deepagents" and rel.name == "deepagents_adapter.py":
431
+ continue
432
+
433
+ rel_str = str(rel).replace("__PACKAGE_PATH__", pkg_path)
434
+ dest = target / rel_str
435
+ if dest.exists() and not force:
436
+ actions.append(f"EXISTS (skipped): {rel_str}")
437
+ continue
438
+
439
+ rendered = _render_content(
440
+ src.read_text(encoding="utf-8"),
441
+ domain=domain,
442
+ framework=resolved_framework,
443
+ java_package=java_package,
444
+ )
445
+ if not dry_run:
446
+ dest.parent.mkdir(parents=True, exist_ok=True)
447
+ dest.write_text(rendered, encoding="utf-8")
448
+ actions.append(f"{'WOULD CREATE' if dry_run else 'CREATE'}: {rel_str}")
449
+
450
+ if stack == "python":
451
+ actions.extend(_update_pyproject(target / "pyproject.toml", dry_run=dry_run))
452
+ elif stack == "java":
453
+ actions.append(
454
+ "NOTE (Java): Ensure test dependencies `org.junit.jupiter:junit-jupiter` (JUnit 5) and "
455
+ "`org.yaml:snakeyaml` are declared in pom.xml / build.gradle."
456
+ )
457
+
458
+ actions.extend(
459
+ _persist_stack_config(
460
+ target,
461
+ stack=stack,
462
+ domain=domain,
463
+ framework=resolved_framework,
464
+ build_tool=resolved_build_tool,
465
+ java_package=java_package,
466
+ project_name=resolved_project_name,
467
+ system_prompt_file=resolved_prompt_file,
468
+ dry_run=dry_run,
469
+ )
470
+ )
471
+ return actions
472
+
473
+
474
+ def main(argv: list[str] | None = None) -> int:
475
+ parser = argparse.ArgumentParser(
476
+ description="Scaffold evoloop evaluation harness into an existing agent repository (brownfield)."
477
+ )
478
+ parser.add_argument("--target", type=Path, default=Path("."), help="Target project root directory.")
479
+ parser.add_argument(
480
+ "--detect",
481
+ action="store_true",
482
+ help="Inspect the target repository (read-only) and print detected stack metadata as JSON.",
483
+ )
484
+ parser.add_argument(
485
+ "--stack",
486
+ default=None,
487
+ choices=sorted(STACK_DEFAULTS),
488
+ help="Target language stack (auto-detected from build manifest when omitted).",
489
+ )
490
+ parser.add_argument("--domain", default="domain", help="Short snake_case domain name (e.g., billing, support).")
491
+ parser.add_argument(
492
+ "--framework",
493
+ default=None,
494
+ help="Agent framework adapter (e.g., deepagents, custom, spring-ai, langchain4j, micronaut).",
495
+ )
496
+ parser.add_argument("--build-tool", default=None, help="Build tool (python: uv; java: maven | gradle).")
497
+ parser.add_argument("--java-package", default=None, help="Base Java package for --stack java.")
498
+ parser.add_argument("--project-name", default=None, help="Override project.name persisted in .evoloop/config.yaml.")
499
+ parser.add_argument(
500
+ "--system-prompt-file",
501
+ default=None,
502
+ help="Relative path to the file containing the agent system prompt.",
503
+ )
504
+ parser.add_argument("--force", action="store_true", help="Overwrite existing scaffold files.")
505
+ parser.add_argument("--dry-run", action="store_true", help="Preview changes without writing files.")
506
+ args = parser.parse_args(argv)
507
+
508
+ if not args.target.is_dir():
509
+ print(f"ERROR: Target directory does not exist: {args.target}", file=sys.stderr)
510
+ return 2
511
+
512
+ resolved_target = args.target.resolve()
513
+ detected = detect_project(resolved_target)
514
+
515
+ if args.detect:
516
+ print(json.dumps(detected, indent=2))
517
+ return 0
518
+
519
+ resolved_stack = args.stack or detected["stack"] or "python"
520
+ resolved_build_tool = args.build_tool or (
521
+ detected["build_tool"] if detected["stack"] == resolved_stack else None
522
+ )
523
+ resolved_framework = args.framework or (
524
+ detected["framework"] if detected["stack"] == resolved_stack else None
525
+ )
526
+ resolved_java_package = args.java_package or detected["java_package"] or "com.example.agent"
527
+
528
+ actions = scaffold_project(
529
+ resolved_target,
530
+ stack=resolved_stack,
531
+ domain=args.domain,
532
+ framework=resolved_framework,
533
+ build_tool=resolved_build_tool,
534
+ java_package=resolved_java_package,
535
+ project_name=args.project_name,
536
+ system_prompt_file=args.system_prompt_file,
537
+ force=args.force,
538
+ dry_run=args.dry_run,
539
+ )
540
+ for line in actions:
541
+ print(line)
542
+ return 0
543
+
544
+
545
+ if __name__ == "__main__":
546
+ raise SystemExit(main())
@@ -0,0 +1,33 @@
1
+ # Golden single-turn and multi-turn agentic flow evaluation scenarios for __DOMAIN_TITLE__
2
+ # Replace starter cases using the evoloop-scenarios skill.
3
+
4
+ cases:
5
+ - id: happy_path_example
6
+ description: Standard domain query calls expected tool and grounds response in tool output.
7
+ category: happy_path
8
+ turns:
9
+ - "Run an example lookup for item-1."
10
+ expected_tool_calls:
11
+ - name: example_tool
12
+ args: { query: "item-1" }
13
+ trajectory_match_mode: unordered
14
+ max_tool_calls: 2
15
+ grounded_any_of:
16
+ - ["item-1"]
17
+ rubric_criteria: >
18
+ The agent must call example_tool for item-1 and present the returned status clearly
19
+ without fabricating extra fields.
20
+
21
+ - id: vague_input_no_tools
22
+ description: Vague request triggers clarification with zero domain tool calls.
23
+ category: input_validation
24
+ turns:
25
+ - "Check that thing for me."
26
+ expected_tool_calls: []
27
+ trajectory_match_mode: strict
28
+ forbidden_tools:
29
+ - example_tool
30
+ max_tool_calls: 0
31
+ rubric_criteria: >
32
+ Because the user did not specify what to look up, the agent must NOT call example_tool
33
+ and must ask one clear clarifying question.
@@ -0,0 +1,9 @@
1
+ # Evaluation Reports
2
+
3
+ This table lists historical live evaluation runs.
4
+ Each row links to the analysis, progress comparison, task list, and raw output.
5
+
6
+ ## Reports
7
+
8
+ | Timestamp | Git HEAD | Command or Mode | Result | Checks | Duration | Analysis | Progress | Tasks | Raw Output |
9
+ | :--- | :---: | :--- | :---: | :---: | :---: | :--- | :--- | :--- | :--- |