d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
71 lines
1.8 KiB
Python
71 lines
1.8 KiB
Python
"""Generate pressure scenarios from skill + spec using LLM."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
from scripts.utils import extract_yaml
|
|
|
|
PROMPTS_DIR = Path(__file__).parent.parent / "prompts"
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Scenario:
|
|
id: str
|
|
level: int
|
|
level_name: str
|
|
description: str
|
|
prompt: str
|
|
setup_commands: tuple[str, ...]
|
|
|
|
|
|
def generate_scenarios(
|
|
skill_path: Path,
|
|
spec_yaml: str,
|
|
model: str = "haiku",
|
|
) -> list[Scenario]:
|
|
"""Generate 3 scenarios with decreasing prompt strictness.
|
|
|
|
Calls claude -p with the scenario_generator prompt, parses YAML output.
|
|
"""
|
|
skill_content = skill_path.read_text()
|
|
prompt_template = (PROMPTS_DIR / "scenario_generator.md").read_text()
|
|
prompt = (
|
|
prompt_template
|
|
.replace("{skill_content}", skill_content)
|
|
.replace("{spec_yaml}", spec_yaml)
|
|
)
|
|
|
|
result = subprocess.run(
|
|
["claude", "-p", prompt, "--model", model, "--output-format", "text"],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=120,
|
|
)
|
|
|
|
if result.returncode != 0:
|
|
raise RuntimeError(f"claude -p failed: {result.stderr}")
|
|
|
|
if not result.stdout.strip():
|
|
raise RuntimeError("claude -p returned empty output")
|
|
|
|
raw_yaml = extract_yaml(result.stdout)
|
|
parsed = yaml.safe_load(raw_yaml)
|
|
|
|
scenarios: list[Scenario] = []
|
|
for s in parsed["scenarios"]:
|
|
scenarios.append(Scenario(
|
|
id=s["id"],
|
|
level=s["level"],
|
|
level_name=s["level_name"],
|
|
description=s["description"],
|
|
prompt=s["prompt"].strip(),
|
|
setup_commands=tuple(s.get("setup_commands", [])),
|
|
))
|
|
|
|
return sorted(scenarios, key=lambda s: s.level)
|