From c908854e7e3571c99cce9f46497ce5337ea0aed1 Mon Sep 17 00:00:00 2001 From: soryu Date: Sun, 25 Jan 2026 03:53:55 +0000 Subject: Update create contract page to use dynamic templates (#29) * feat: Add contract type templates API endpoint Add a new API endpoint to provide contract type templates (workflow definitions) separate from file templates. This enables the create contract page to dynamically show available contract types. Changes: - Add ContractTypeTemplate struct in templates.rs with id, name, description, phases, default_phase, and is_builtin fields - Add built-in contract types: 'simple' (plan/execute) and 'specification' (research/specify/plan/execute/review) - Add GET /api/v1/contract-types endpoint returning all contract types - Add frontend ContractTypeTemplate interface and listContractTypes() API function Co-Authored-By: Claude Opus 4.5 * feat: Update create contract modal to use dynamic templates - Add ContractTypeTemplate interface and listContractTypes API function to frontend api.ts - Add GET /api/v1/contract-types backend endpoint that returns built-in contract types (simple, specification) with their phases and defaults - Update create contract modal to fetch contract types dynamically when opened, with loading state and fallback to hardcoded types on error - Dynamically render contract type selection buttons from fetched types - Update phase dropdown to use phases from selected contract type - Replace static getValidPhases/getDefaultPhase calls with dynamic data Co-Authored-By: Claude Opus 4.5 --------- Co-authored-by: Claude Opus 4.5 --- makima/src/llm/templates.rs | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'makima/src/llm/templates.rs') diff --git a/makima/src/llm/templates.rs b/makima/src/llm/templates.rs index 18ef46d..7a5bd38 100644 --- a/makima/src/llm/templates.rs +++ b/makima/src/llm/templates.rs @@ -8,6 +8,71 @@ use utoipa::ToSchema; use crate::db::models::BodyElement; +// ============================================================================= +// Contract Type Templates (Workflow Definitions) +// ============================================================================= + +/// A contract type template defining a workflow +#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct ContractTypeTemplate { + /// Unique identifier (e.g., 'simple', 'specification', 'feature-development') + pub id: String, + /// Display name + pub name: String, + /// What this contract type is for + pub description: String, + /// Ordered list of phases in the workflow + pub phases: Vec, + /// Starting phase + pub default_phase: String, + /// True for built-in types ('simple', 'specification') + pub is_builtin: bool, +} + +/// Get all available contract type templates +pub fn all_contract_types() -> Vec { + vec![ + simple_contract_type(), + specification_contract_type(), + ] +} + +/// Simple contract type with basic plan/execute workflow +fn simple_contract_type() -> ContractTypeTemplate { + ContractTypeTemplate { + id: "simple".to_string(), + name: "Simple".to_string(), + description: "A basic workflow for straightforward tasks with planning and execution phases." + .to_string(), + phases: vec!["plan".to_string(), "execute".to_string()], + default_phase: "plan".to_string(), + is_builtin: true, + } +} + +/// Specification contract type with full research-to-review workflow +fn specification_contract_type() -> ContractTypeTemplate { + ContractTypeTemplate { + id: "specification".to_string(), + name: "Specification".to_string(), + description: "A comprehensive workflow for complex projects requiring research, specification, planning, execution, and review.".to_string(), + phases: vec![ + "research".to_string(), + "specify".to_string(), + "plan".to_string(), + "execute".to_string(), + "review".to_string(), + ], + default_phase: "research".to_string(), + is_builtin: true, + } +} + +// ============================================================================= +// File Templates +// ============================================================================= + /// A file template with suggested structure #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] pub struct FileTemplate { -- cgit v1.2.3