Add subagent prompts and implement company workflow orchestration

- Introduced prompts for various subagent roles: architecture reviewer, code quality reviewer, documentation maintainer, implementation team, testing team, and security reviewer.
- Implemented the auto-subagent orchestration in `auto.rs` to manage inline and background reviews.
- Created a division structure in `division.rs` to define roles and responsibilities for each subagent.
- Developed a company workflow orchestrator in `company.rs` to run the complete division pipeline, consolidating findings and generating executive summaries.
- Added logic to determine whether to run a full or quick pipeline based on request complexity.
This commit is contained in:
asepharyana
2026-07-13 05:23:38 +07:00
parent 2856dd78b8
commit a6eed9e574
21 changed files with 1577 additions and 85 deletions
+41 -22
View File
@@ -67,9 +67,14 @@ impl WorkflowEngine {
/// Shared live state used by `run_workflow_tracked` to push real-time
/// agent status updates into the TUI's `WorkflowEngine`.
///
/// The closure receives `(agent_id, new_status)` and should update the
/// corresponding agent in `AppStateRest::workflow_engine`.
pub type LiveStateFn = Arc<dyn Fn(String, AgentStatus) + Send + Sync>;
/// The closure receives `(agent_id, agent_name, new_status)`:
/// - `agent_id`: unique identifier (UUID) for upserting the agent.
/// - `agent_name`: human-readable display name for the TUI panel.
/// - `status`: the agent's lifecycle state and timing.
///
/// Callers should use `agent_id` as the stable key and `agent_name` for
/// display purposes (e.g. the division name in the company pipeline).
pub type LiveStateFn = Arc<dyn Fn(String, String, AgentStatus) + Send + Sync>;
/// Spawn a single synchronous subagent with the given prompt, passing it
/// any findings from earlier sibling agents. Updates live state before and
@@ -107,14 +112,20 @@ fn spawn_single_agent(
let started_at = chrono::Utc::now().timestamp_millis();
// Notify UI: this agent is now running
// Notify UI: this agent is now running.
// Pass both the unique agent_id (UUID for stable key) and agent_name
// (human-readable display name, e.g. division name).
if let Some(f) = live {
f(agent_id.to_string(), AgentStatus {
state: AgentState::Running,
started_at: Some(started_at),
completed_at: None,
error: None,
});
f(
agent_id.to_string(),
agent_name.to_string(),
AgentStatus {
state: AgentState::Running,
started_at: Some(started_at),
completed_at: None,
error: None,
},
);
}
let def = AgentDefinition::new(agent_name.to_string(), "coder".to_string())
@@ -207,18 +218,26 @@ fn spawn_single_agent(
// Notify UI: agent completed or failed
if let Some(f) = live {
match &result {
Ok(_) => f(agent_id.to_string(), AgentStatus {
state: AgentState::Completed,
started_at: Some(started_at),
completed_at: Some(completed_at),
error: None,
}),
Err(e) => f(agent_id.to_string(), AgentStatus {
state: AgentState::Failed,
started_at: Some(started_at),
completed_at: Some(completed_at),
error: Some(e.to_string()),
}),
Ok(_) => f(
agent_id.to_string(),
agent_name.to_string(),
AgentStatus {
state: AgentState::Completed,
started_at: Some(started_at),
completed_at: Some(completed_at),
error: None,
},
),
Err(e) => f(
agent_id.to_string(),
agent_name.to_string(),
AgentStatus {
state: AgentState::Failed,
started_at: Some(started_at),
completed_at: Some(completed_at),
error: Some(e.to_string()),
},
),
}
}