Loading...
Loading...
Convert an existing codebase in the current working directory into a ShinkaEvolve task directory by snapshotting the relevant code, adding evolve blocks, and generating `evaluate.py` plus Shinka runner/config files. Use when the user wants to optimize existing code with Shinka instead of creating a brand-new task from a natural-language description.
npx skill4agent add sakanaai/shinkaevolve shinka-convertshinka-setupshinka-setupshinka-convertshinka-runmetrics.jsoncorrect.jsonEVOLVE-BLOCKevaluate.pyinitial.<ext>shinka-run./shinka_task/evaluate.pyrun_evo.pyshinka.yamlinitial.<ext>./shinka_task/initial.<ext>shinka-runEVOLVE-BLOCK-STARTEVOLVE-BLOCK-ENDrun_experiment(...)run_shinka_evalsubprocessmetrics.jsoncorrect.jsonrun_evo.pyshinka.yamlinit_program_pathlanguageshinka-runpython evaluate.py --program_path <initial file> --results_dir /tmp/shinka_convert_smokeshinka-runrun_experiment(...)run_shinka_evalevaluate.pymetrics.jsoncorrect.jsonresults_dircombined_scorepublicprivateextra_datatext_feedbackcorrecterrorcombined_scorefrom __future__ import annotations
# EVOLVE-BLOCK-START
def optimize_me(...):
...
# EVOLVE-BLOCK-END
def run_experiment(random_seed: int | None = None, **kwargs):
...
return score, text_feedbackfrom shinka.core import run_shinka_eval
def main(program_path: str, results_dir: str):
metrics, correct, err = run_shinka_eval(
program_path=program_path,
results_dir=results_dir,
experiment_fn_name="run_experiment",
num_runs=3,
get_experiment_kwargs=get_kwargs,
aggregate_metrics_fn=aggregate_fn,
validate_fn=validate_fn,
)
if not correct:
raise RuntimeError(err or "Evaluation failed")evaluate.pyimport json
import os
from pathlib import Path
def main(program_path: str, results_dir: str):
os.makedirs(results_dir, exist_ok=True)
metrics = {
"combined_score": 0.0,
"public": {},
"private": {},
"extra_data": {},
"text_feedback": "",
}
correct = {"correct": False, "error": ""}
(Path(results_dir) / "metrics.json").write_text(json.dumps(metrics, indent=2))
(Path(results_dir) / "correct.json").write_text(json.dumps(correct, indent=2))scripts/run_evo.pyscripts/shinka.yamlshinka-run