From 5ac86dccadea53b33bc1a29bba10fb04996a6515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=20=E9=A7=BF=E7=94=AB=20=28Shunsuke=20Hayashi=29?= Date: Fri, 10 Apr 2026 10:00:25 +0900 Subject: [PATCH] feat(protocol): attach GNI depth-1 impact files to context When build_context_attachments runs, it now also includes files from TaskImpact.depth1 as "impact_depth1" attachments. Files already attached via locked_files are skipped to avoid duplication. This improves context accuracy by giving agents visibility into direct callers/importers that may be affected by their changes. Closes #89 Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/miyabi-core/src/protocol.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/miyabi-core/src/protocol.rs b/crates/miyabi-core/src/protocol.rs index 8198168..8c461bc 100644 --- a/crates/miyabi-core/src/protocol.rs +++ b/crates/miyabi-core/src/protocol.rs @@ -858,6 +858,36 @@ impl DeterministicExecutionProtocol { } } + // Attach depth-1 impact files (direct callers/importers) + if let Some(impact) = &task.impact { + let locked_files: std::collections::HashSet<&str> = task + .lock + .as_ref() + .map(|l| l.affected_files.iter().map(|f| f.as_str()).collect()) + .unwrap_or_default(); + for dep_file in &impact.depth1 { + if remaining_tokens == 0 { + break; + } + if locked_files.contains(dep_file.as_str()) { + continue; + } + let source_path = self.resolve_attachment_path(dep_file); + if !source_path.exists() { + continue; + } + let content = read_file_snippet(&source_path, FILE_SNIPPET_LINE_LIMIT) + .map_err(ProtocolError::from)?; + push_attachment( + &mut attachments, + &mut remaining_tokens, + "impact_depth1", + &source_path.display().to_string(), + &content, + ); + } + } + Ok(attachments) }