31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
|
|
from control_plane.resources.models import Resource
|
|
from model_router.providers import SolProvider
|
|
from model_router.router import ModelRequestContract
|
|
from project_brain.planning import PlanValidationError, parse_project_plan_response
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = "Opt-in smoke test: ask Sol on Spark for a structured project plan and validate it."
|
|
|
|
def add_arguments(self, parser):
|
|
parser.add_argument("goal")
|
|
|
|
def handle(self, *args, **options):
|
|
resource = Resource.objects.filter(provider="opencode", is_active=True).first()
|
|
if resource is None:
|
|
raise CommandError("No Sol/opencode resource configured. Run seed_spark_resources first.")
|
|
prompt = (
|
|
"Return only JSON with a project_plan object. Include goal, scope, acceptance_criteria, "
|
|
"milestones, features, tasks with id, goal, acceptance_criteria, dependencies. Goal: "
|
|
+ options["goal"]
|
|
)
|
|
response = SolProvider(resource).complete(ModelRequestContract(purpose="PLANNING", prompt=prompt, token_budget=4000))
|
|
try:
|
|
contract = parse_project_plan_response(response.content)
|
|
except PlanValidationError as exc:
|
|
raise CommandError(f"Sol returned invalid plan: {exc}") from exc
|
|
self.stdout.write(self.style.SUCCESS(f"Validated Sol plan: {contract.goal}"))
|