//! Company-style agent divisions: specialized subagent roles that form an //! organizational hierarchy like a company. //! //! ```text //! CEO (Main Agent) //! ├── Strategy Division (planner) — architecture, diagrams, plan //! ├── Engineering Division (coder) — implementation //! ├── Quality Division (tester) — review, test //! ├── Security Division (auditor) — security audit //! └── Documentation Division (doc) — documentation //! ``` //! //! Each division has a specific role, tools, and system prompt tailored to //! its function. The main agent (CEO) delegates work to divisions via //! the company pipeline workflow. use crate::app::subagent::spawn::AgentDefinition; /// Division roles — used as both the `role` field in `AgentDefinition` /// and as the key for pipeline routing. pub mod roles { /// Strategy Division: plans architecture, creates diagrams, breaks down work. pub const STRATEGY: &str = "planner"; /// Engineering Division: implements code per the plan. pub const ENGINEERING: &str = "coder"; /// Quality Division: reviews implementation, writes tests. pub const QUALITY: &str = "tester"; /// Security Division: audits for vulnerabilities. pub const SECURITY: &str = "auditor"; /// Documentation Division: updates docs, README, inline documentation. pub const DOCUMENTATION: &str = "documenter"; } /// ─── Division Agent Definitions ─── /// /// Build the Strategy Division agent — chief architect and planner. /// /// Tools: read-only (read, grep, glob, search, lsp, plan, seqthink, recall) /// Role: never writes code; produces detailed plans with mermaid diagrams. pub fn strategy_division() -> AgentDefinition { AgentDefinition::new( "strategy-division".to_string(), roles::STRATEGY.to_string(), ) .with_system_prompt(crate::resources::DIVISION_PLANNER_PROMPT.to_string()) .with_max_steps(15) .with_allowed_tools(vec![ "read".to_string(), "grep".to_string(), "glob".to_string(), "search".to_string(), "seqthink".to_string(), "plan".to_string(), "recall".to_string(), "lsp_connect".to_string(), "lsp_diagnostics".to_string(), "lsp_hover".to_string(), "lsp_definition".to_string(), "lsp_references".to_string(), ]) } /// Build the Engineering Division agent — implements code per the plan. /// /// Tools: full access (all write/edit/bash/git/LSP tools) /// Role: executes the strategy plan, one file at a time. pub fn engineering_division() -> AgentDefinition { AgentDefinition::new( "engineering-division".to_string(), roles::ENGINEERING.to_string(), ) .with_system_prompt(crate::resources::DIVISION_IMPLEMENTER_PROMPT.to_string()) .with_max_steps(50) .with_allowed_tools(vec![ "read".to_string(), "write".to_string(), "edit".to_string(), "delete".to_string(), "bash".to_string(), "grep".to_string(), "glob".to_string(), "git_operator".to_string(), "seqthink".to_string(), "lsp_connect".to_string(), "lsp_diagnostics".to_string(), "lsp_hover".to_string(), "lsp_definition".to_string(), "lsp_references".to_string(), "lsp_completion".to_string(), "lsp_disconnect".to_string(), "todowrite".to_string(), "todofinish".to_string(), ]) } /// Build the Quality Division agent — reviews code and writes tests. /// /// Tools: read, write, grep, glob, bash (for running tests), LSP, memory /// Role: verifies correctness and creates/runs tests. pub fn quality_division() -> AgentDefinition { AgentDefinition::new( "quality-division".to_string(), roles::QUALITY.to_string(), ) .with_system_prompt(crate::resources::DIVISION_TESTER_PROMPT.to_string()) .with_max_steps(30) .with_allowed_tools(vec![ "read".to_string(), "write".to_string(), "edit".to_string(), "grep".to_string(), "glob".to_string(), "bash".to_string(), "seqthink".to_string(), "recall".to_string(), "remember".to_string(), "lsp_connect".to_string(), "lsp_diagnostics".to_string(), "lsp_hover".to_string(), "lsp_definition".to_string(), "lsp_references".to_string(), ]) } /// Build the Security Division agent — security auditor. /// /// Tools: read-only + search + memory /// Role: audits implementation for vulnerabilities. pub fn security_division() -> AgentDefinition { AgentDefinition::new( "security-division".to_string(), roles::SECURITY.to_string(), ) .with_system_prompt(crate::resources::SECURITY_REVIEWER_PROMPT.to_string()) .with_max_steps(15) .with_allowed_tools(vec![ "read".to_string(), "grep".to_string(), "glob".to_string(), "search".to_string(), "seqthink".to_string(), "recall".to_string(), "remember".to_string(), "lsp_connect".to_string(), "lsp_diagnostics".to_string(), "lsp_hover".to_string(), "lsp_definition".to_string(), "lsp_references".to_string(), ]) } /// Build the Documentation Division agent — documentation maintainer. /// /// Tools: read, grep, glob, write, edit, memory /// Role: updates README, inline docs, architecture docs. pub fn documentation_division() -> AgentDefinition { AgentDefinition::new( "documentation-division".to_string(), roles::DOCUMENTATION.to_string(), ) .with_system_prompt(crate::resources::DIVISION_DOCUMENTER_PROMPT.to_string()) .with_max_steps(15) .with_allowed_tools(vec![ "read".to_string(), "write".to_string(), "edit".to_string(), "grep".to_string(), "glob".to_string(), "recall".to_string(), "remember".to_string(), ]) } /// ─── Division Registry ─── /// /// A named division with its agent definition and display metadata. #[derive(Debug, Clone)] pub struct Division { /// Display name for the division (e.g. "Strategy", "Engineering"). pub name: &'static str, /// Role tag used for pipeline routing (matches `roles::*` constants). #[allow(dead_code)] pub role: &'static str, /// One-line description of what this division does. #[allow(dead_code)] pub description: &'static str, /// Agent definition with tools, prompt, and step budget. pub agent_def: AgentDefinition, } impl Division { pub fn new( name: &'static str, role: &'static str, description: &'static str, agent_def: AgentDefinition, ) -> Self { Division { name, role, description, agent_def } } } /// Return all company divisions as an ordered list matching the pipeline flow: /// Strategy → Engineering → Quality → Security → Documentation. pub fn all_divisions() -> Vec { vec![ Division::new( "Strategy", roles::STRATEGY, "Architecture planning with diagrams and step-by-step breakdown", strategy_division(), ), Division::new( "Engineering", roles::ENGINEERING, "Code implementation following the plan", engineering_division(), ), Division::new( "Quality", roles::QUALITY, "Code review and comprehensive testing", quality_division(), ), Division::new( "Security", roles::SECURITY, "Security vulnerability audit", security_division(), ), Division::new( "Documentation", roles::DOCUMENTATION, "Documentation updates and maintenance", documentation_division(), ), ] }