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) <noreply@anthropic.com>
This commit is contained in:
林 駿甫 (Shunsuke Hayashi) 2026-04-10 10:00:25 +09:00
parent 32f034e2b2
commit 5ac86dccad

View file

@ -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)
}