feat: ui
This commit is contained in:
61
src/controller/executor.rs
Normal file
61
src/controller/executor.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
use std::sync::mpsc::Sender;
|
||||
|
||||
use anyhow::Result;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::app::AppEvent;
|
||||
use crate::model::{ExecutionResponse, Plan, PlanStep, SessionSource, TaskConfig};
|
||||
use crate::process;
|
||||
use crate::storage::toon;
|
||||
|
||||
pub fn implement(
|
||||
repo_root: &std::path::Path,
|
||||
config: &TaskConfig,
|
||||
plan: &Plan,
|
||||
step: &PlanStep,
|
||||
event_tx: &Sender<AppEvent>,
|
||||
) -> Result<ExecutionResponse> {
|
||||
let goal_md = toon::read_markdown(&config.goal_file)?;
|
||||
let standards_md = toon::read_markdown(&config.standards_file)?;
|
||||
let prompt = format!(
|
||||
concat!(
|
||||
"You are the autonomous execution worker for a Rust TUI-first controller.\n",
|
||||
"You are in execution mode. Do not ask the user questions.\n",
|
||||
"Implement the step, verify it, clean up the implementation, and leave the codebase in maintainable condition.\n",
|
||||
"You may edit files in the repository. You own the implementation decisions.\n",
|
||||
"If the goal itself is ambiguous, set needs_goal_clarification=true.\n",
|
||||
"Return verification commands and test commands that the controller should run after your work.\n\n",
|
||||
"Goal:\n{goal}\n\n",
|
||||
"Standards:\n{standards}\n\n",
|
||||
"Current plan:\n{plan}\n\n",
|
||||
"Active step:\n{step}\n"
|
||||
),
|
||||
goal = goal_md,
|
||||
standards = standards_md,
|
||||
plan = serde_json::to_string_pretty(plan)?,
|
||||
step = serde_json::to_string_pretty(step)?,
|
||||
);
|
||||
|
||||
let schema = json!({
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["status", "summary", "verification_commands", "test_commands", "notes", "needs_goal_clarification"],
|
||||
"properties": {
|
||||
"status": { "type": "string", "enum": ["done", "blocked", "needs-replan"] },
|
||||
"summary": { "type": "string" },
|
||||
"verification_commands": { "type": "array", "items": { "type": "string" } },
|
||||
"test_commands": { "type": "array", "items": { "type": "string" } },
|
||||
"notes": { "type": "array", "items": { "type": "string" } },
|
||||
"needs_goal_clarification": { "type": "boolean" }
|
||||
}
|
||||
});
|
||||
let raw = process::run_codex_with_schema(
|
||||
repo_root,
|
||||
&prompt,
|
||||
&schema,
|
||||
event_tx,
|
||||
SessionSource::Executor,
|
||||
Some(step.id.clone()),
|
||||
)?;
|
||||
Ok(serde_json::from_str(&raw)?)
|
||||
}
|
||||
Reference in New Issue
Block a user