Skip to content

Commit 583e49d

Browse files
author
zocomputer
committed
next version
1 parent 7f312a7 commit 583e49d

18 files changed

Lines changed: 3278 additions & 2800 deletions

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "optimize-anything",
3-
"version": "0.3.1",
3+
"version": "0.3.5",
44
"description": "Optimize any text artifact using gepa — prompts, code, configs, skills",
55
"keywords": ["optimization", "gepa", "prompts", "evaluator"],
66
"author": {

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ dogfood_runs/
2727
PROMPT.md
2828
.coverage
2929
run.log
30+
ROADMAP*
31+
runs/

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## v0.3.5 - 2026-03-20
4+
5+
### Structural refactor
6+
- Extracted `cli.py` monolith (1,639 lines) into 4 focused modules:
7+
- `preflight.py` — evaluator preflight validation checks
8+
- `persist.py` — run-directory persistence, diff output, artifact writing
9+
- `cli_optimize.py` — optimize subcommand implementation
10+
- `cli_tools.py` — score, validate, analyze, explain, budget, intake, generate-evaluator subcommands
11+
- `cli.py` reduced to ~500 lines: argparse dispatcher + shared utilities
12+
13+
### New features
14+
- Added `budget_utilization` section to optimize output contract with `requested`, `evaluator_calls`, `candidates_accepted`, and `efficiency` fields for transparent budget tracking
15+
16+
### Verification
17+
- All 307 unit tests pass
18+
- Doc contract and score check gates pass
19+
- No circular import issues with extracted modules
20+
321
## v0.3.2 - 2026-03-09
422

523
### Improvements

CONCEPTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,4 @@ These are independent axes:
9898
- `plateau_detected`, `plateau_guidance`
9999
- optional `evaluator_failure_signal`
100100
- optional `early_stopped`, `stopped_at_iteration`
101+
- `budget_utilization` — breakdown of requested budget vs actual evaluator calls, accepted candidates, and efficiency ratio

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ optimize-anything optimize seed.txt \
130130

131131
optimize-anything is also a Claude Code plugin with guided slash commands and skills.
132132

133+
### Plugin Regression Workflow
134+
135+
Use the regression harness when you want to verify that Claude can actually invoke the plugin correctly end-to-end, not merely that the CLI itself still works.
136+
137+
```bash
138+
# Direct plugin regression run
139+
uv run python scripts/plugin_regression.py
140+
141+
# Full repo validation including plugin regression
142+
uv run python scripts/check.py --with-plugin
143+
```
144+
145+
Requirements:
146+
- `claude` CLI installed and authenticated
147+
- `OPENAI_API_KEY` set in the shell that launches the command
148+
- `ANTHROPIC_API_KEY` set in the shell that launches the command
149+
150+
The harness runs three real scenarios (`analyze`, `validate`, `quick`), saves Claude JSON outputs plus stderr logs, and fails if Claude does not execute the expected workflow or the optimized artifact is not written.
151+
133152
### Installation
134153

135154
```bash
@@ -193,6 +212,7 @@ CLI stdout returns a JSON summary with these fields:
193212
- `plateau_detected`, `plateau_guidance`
194213
- optional `evaluator_failure_signal`
195214
- optional `early_stopped`, `stopped_at_iteration`
215+
- `budget_utilization` (`requested`, `evaluator_calls`, `candidates_accepted`, `efficiency`)
196216

197217
### Evaluator Protocol (v2)
198218

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "optimize-anything"
3-
version = "0.3.2"
3+
version = "0.3.5"
44
description = "Optimize any text artifact using gepa — prompts, code, configs, skills"
55
readme = "README.md"
66
license = {text = "MIT"}

scripts/check.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,20 @@ def _run_gate(label: str, cmd: list[str], cwd: Path) -> bool:
3434

3535
def main(argv: list[str] | None = None) -> int:
3636
parser = argparse.ArgumentParser(
37-
description="Run all validation gates: pytest, smoke harness, score check."
37+
description="Run validation gates: pytest, smoke harness, optional plugin regression, score check."
3838
)
3939
parser.add_argument(
4040
"--skip-smoke",
4141
action="store_true",
4242
default=False,
4343
help="Skip the smoke harness gate (use for offline testing).",
4444
)
45+
parser.add_argument(
46+
"--with-plugin",
47+
action="store_true",
48+
default=False,
49+
help="Include the Claude Code plugin regression gate (requires Claude CLI + API keys).",
50+
)
4551
args = parser.parse_args(argv)
4652

4753
root = Path(__file__).parent.parent.resolve()
@@ -68,7 +74,19 @@ def main(argv: list[str] | None = None) -> int:
6874
)
6975
results.append(("smoke harness", passed))
7076

71-
# Gate 3: score check
77+
# Gate 3: plugin regression
78+
if args.with_plugin:
79+
passed = _run_gate(
80+
"plugin regression",
81+
["uv", "run", "python", "scripts/plugin_regression.py"],
82+
cwd=root,
83+
)
84+
results.append(("plugin regression", passed))
85+
else:
86+
print("\n[SKIP] plugin regression (--with-plugin not set)")
87+
results.append(("plugin regression", "SKIP"))
88+
89+
# Gate 4: score check
7290
passed = _run_gate(
7391
"score check",
7492
["uv", "run", "python", "scripts/score_check.py"],

scripts/plugin_eval.sh

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env bash
2+
# Plugin evaluation harness for optimize-anything as a Claude Code plugin.
3+
#
4+
# Usage:
5+
# ./scripts/plugin_eval.sh [scenario]
6+
#
7+
# Scenarios:
8+
# budget - Lightweight budget estimation (no LLM calls)
9+
# analyze - Single LLM call to analyze artifact quality dimensions
10+
# validate - Cross-provider validation (2+ providers)
11+
# quick - Full optimization loop (most expensive)
12+
# all - Run all scenarios sequentially
13+
#
14+
# Requirements:
15+
# - claude CLI installed and authenticated
16+
# - OPENAI_API_KEY and/or ANTHROPIC_API_KEY set
17+
# - This script must be run from the repo root
18+
19+
set -euo pipefail
20+
21+
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
22+
PLUGIN_DIR="$REPO_ROOT"
23+
RESULTS_DIR="$REPO_ROOT/runs/plugin-eval"
24+
SEED_FILE="$REPO_ROOT/runs/zo-eval/seed.txt"
25+
26+
SCENARIO="${1:-all}"
27+
28+
mkdir -p "$RESULTS_DIR"
29+
30+
# Common claude flags
31+
CLAUDE_BASE=(
32+
claude -p
33+
--plugin-dir "$PLUGIN_DIR"
34+
--output-format json
35+
--allowedTools "Bash Read Write Edit Glob Grep"
36+
--max-budget-usd 0.50
37+
)
38+
39+
timestamp() {
40+
date -u +"%Y%m%dT%H%M%SZ"
41+
}
42+
43+
run_scenario() {
44+
local name="$1"
45+
local prompt="$2"
46+
local outfile="$RESULTS_DIR/${name}-$(timestamp).json"
47+
48+
echo "=== Scenario: $name ==="
49+
echo "Prompt: $prompt"
50+
echo "Output: $outfile"
51+
echo ""
52+
53+
local start_time
54+
start_time=$(date +%s)
55+
56+
# Run claude in print mode with the plugin loaded
57+
"${CLAUDE_BASE[@]}" "$prompt" > "$outfile" 2>"$RESULTS_DIR/${name}-stderr.log" || true
58+
59+
local end_time
60+
end_time=$(date +%s)
61+
local elapsed=$(( end_time - start_time ))
62+
63+
echo "Completed in ${elapsed}s"
64+
echo "---"
65+
66+
# Quick validation: check if output is valid JSON
67+
if jq empty "$outfile" 2>/dev/null; then
68+
echo "Output: valid JSON"
69+
# Extract cost if available
70+
jq -r '.cost_usd // "n/a"' "$outfile" 2>/dev/null || true
71+
else
72+
echo "Output: not valid JSON (check file manually)"
73+
fi
74+
echo ""
75+
}
76+
77+
scenario_budget() {
78+
run_scenario "budget" \
79+
"Use the optimize-anything plugin to estimate a budget for the seed file at $SEED_FILE. Run: optimize-anything budget $SEED_FILE"
80+
}
81+
82+
scenario_analyze() {
83+
run_scenario "analyze" \
84+
"Use the optimize-anything plugin to analyze the artifact at $SEED_FILE for quality dimensions. Run: optimize-anything analyze $SEED_FILE --judge-model openai/gpt-4o-mini --objective 'Score the quality of this system prompt'"
85+
}
86+
87+
scenario_validate() {
88+
run_scenario "validate" \
89+
"Use the optimize-anything plugin to validate the artifact at $SEED_FILE across multiple providers. Run: optimize-anything validate $SEED_FILE --providers openai/gpt-4o-mini anthropic/claude-haiku-4-5-20251001 --objective 'Score the quality and clarity of this system prompt'"
90+
}
91+
92+
scenario_quick() {
93+
run_scenario "quick" \
94+
"Use the optimize-anything plugin to quickly optimize the seed at $SEED_FILE. Run: optimize-anything optimize $SEED_FILE --judge-model openai/gpt-4o-mini --objective 'Improve clarity and specificity of this system prompt' --budget 5 --model openai/gpt-4o-mini --output $RESULTS_DIR/quick-best.txt"
95+
}
96+
97+
case "$SCENARIO" in
98+
budget) scenario_budget ;;
99+
analyze) scenario_analyze ;;
100+
validate) scenario_validate ;;
101+
quick) scenario_quick ;;
102+
all)
103+
scenario_budget
104+
scenario_analyze
105+
scenario_validate
106+
scenario_quick
107+
echo "=== All scenarios complete ==="
108+
echo "Results in: $RESULTS_DIR"
109+
;;
110+
*)
111+
echo "Unknown scenario: $SCENARIO"
112+
echo "Valid: budget, analyze, validate, quick, all"
113+
exit 1
114+
;;
115+
esac

0 commit comments

Comments
 (0)