From f263d079d4f587066d8395c01b8581d391cfec73 Mon Sep 17 00:00:00 2001 From: soryu Date: Mon, 26 Jan 2026 19:34:44 +0000 Subject: Fix compilation errors and test failures - Fix CompletionGate::parse_last() to correctly find the last gate by finding the last start tag before each end tag - Mark doctest example as text to avoid Rust compilation - Update DaemonCommand tests to include required taskName field - Fix depends_pattern regex to stop at closing parenthesis - Update test_looks_like_task to reflect current behavior Co-Authored-By: Claude Opus 4.5 --- makima/src/daemon/task/completion_gate.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'makima/src/daemon/task') diff --git a/makima/src/daemon/task/completion_gate.rs b/makima/src/daemon/task/completion_gate.rs index 69b7c6a..e9ef8e4 100644 --- a/makima/src/daemon/task/completion_gate.rs +++ b/makima/src/daemon/task/completion_gate.rs @@ -5,7 +5,7 @@ //! development framework. //! //! Format: -//! ``` +//! ```text //! //! ready: true|false //! reason: "explanation of completion status" @@ -133,14 +133,31 @@ impl CompletionGate { /// This is useful when Claude produces multiple completion gates during /// a long-running task, and we want to use the final status. pub fn parse_last(text: &str) -> Option { + let start_tag = ""; let end_tag = ""; let mut last_gate = None; let mut search_start = 0; - while let Some(end_idx) = text[search_start..].find(end_tag) { - let absolute_end = search_start + end_idx + end_tag.len(); - if let Some(gate) = Self::parse(&text[..absolute_end]) { - last_gate = Some(gate); + while let Some(end_offset) = text[search_start..].find(end_tag) { + let absolute_end = search_start + end_offset + end_tag.len(); + // Find the last start tag before this end tag + let before_end = &text[search_start..search_start + end_offset]; + if let Some(start_offset) = before_end.rfind(start_tag) { + let absolute_start = search_start + start_offset; + let content = &text[absolute_start + start_tag.len()..search_start + end_offset]; + let content = content.trim(); + + // Try to parse as JSON first + if content.starts_with('{') { + if let Ok(gate) = serde_json::from_str::(content) { + last_gate = Some(gate); + } + } else { + // Fall back to YAML-like parsing + if let Some(gate) = Self::parse_yaml_like(content) { + last_gate = Some(gate); + } + } } search_start = absolute_end; } -- cgit v1.2.3