diff options
| author | soryu <soryu@soryu.co> | 2026-01-26 19:34:44 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-01-26 19:34:44 +0000 |
| commit | f263d079d4f587066d8395c01b8581d391cfec73 (patch) | |
| tree | 7d1e2e52bf59439799e61d34d41b6796498acec9 /makima/src/daemon/task | |
| parent | ccfcf753f67541b5fba8746f4f60d7498a54f44a (diff) | |
| download | soryu-f263d079d4f587066d8395c01b8581d391cfec73.tar.gz soryu-f263d079d4f587066d8395c01b8581d391cfec73.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/daemon/task')
| -rw-r--r-- | makima/src/daemon/task/completion_gate.rs | 27 |
1 files changed, 22 insertions, 5 deletions
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 //! <COMPLETION_GATE> //! 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<Self> { + let start_tag = "<COMPLETION_GATE>"; let end_tag = "</COMPLETION_GATE>"; 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::<CompletionGate>(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; } |
