Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(doctor): report antigravity-cli native memory and probe with harness payload (#1745)

Felipe Neves Ricardo8c993a8d4d2b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dd6e0f13..744cc58a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,11 @@ version in [`docs/changelog/`](docs/changelog/):
## [Unreleased]
+### Fixed
+
+- Fixed `ai-memory doctor` native memory inspection omitting Antigravity CLI
+ and using a Claude-only synthetic probe (#1745).
+
## [3.2.6] - 2026-10-26
### Fixed
diff --git a/crates/ai-memory-cli/src/commands/doctor.rs b/crates/ai-memory-cli/src/commands/doctor.rs
index bce55698..6c664bdf 100644
--- a/crates/ai-memory-cli/src/commands/doctor.rs
+++ b/crates/ai-memory-cli/src/commands/doctor.rs
@@ -340,7 +340,44 @@ pub(crate) fn relocated_session_dir_with(
/// platform-specific directory name. A harness left out of this list simply
/// produces no report line, which is the documented behavior for "location
/// unknown" rather than an error.
-const HARNESSES_WITH_KNOWN_NATIVE_MEMORY: &[ManagedHarness] = &[ManagedHarness::Claude];
+const HARNESSES_WITH_KNOWN_NATIVE_MEMORY: &[ManagedHarness] =
+ &[ManagedHarness::Claude, ManagedHarness::Antigravity];
+
+fn count_regular_files_recursive(dir: &Path) -> usize {
+ let mut count = 0;
+ let mut stack = vec![dir.to_path_buf()];
+ while let Some(current) = stack.pop() {
+ let Ok(entries) = std::fs::read_dir(&current) else {
+ continue;
+ };
+ for entry in entries.flatten() {
+ let Ok(ft) = entry.file_type() else {
+ continue;
+ };
+ if ft.is_file() {
+ count += 1;
+ } else if ft.is_dir() {
+ stack.push(entry.path());
+ }
+ }
+ }
+ count
+}
+
+fn synthetic_read_probe(harness: ManagedHarness, probe_path: &Path) -> serde_json::Value {
+ match harness {
+ ManagedHarness::Antigravity => serde_json::json!({
+ "toolCall": {
+ "name": "view_file",
+ "args": { "AbsolutePath": probe_path.to_string_lossy() },
+ }
+ }),
+ _ => serde_json::json!({
+ "tool_name": "Read",
+ "tool_input": { "file_path": probe_path.to_string_lossy() },
+ }),
+ }
+}
/// For every harness in [`HARNESSES_WITH_KNOWN_NATIVE_MEMORY`] that actually
/// has a memory store for this checkout, report its location, how many
@@ -375,23 +412,23 @@ fn native_memory_reports(home: &Path, cwd: &Path) -> Vec<NativeMemoryReport> {
else {
continue;
};
- let file_count = std::fs::read_dir(&memory_dir)
- .map(|entries| {
- entries
- .filter_map(Result::ok)
- .filter(|entry| entry.file_type().is_ok_and(|ft| ft.is_file()))
- .count()
- })
- .unwrap_or(0);
+ let file_count = match harness {
+ ManagedHarness::Antigravity => count_regular_files_recursive(&memory_dir),
+ _ => std::fs::read_dir(&memory_dir)
+ .map(|entries| {
+ entries
+ .filter_map(Result::ok)
+ .filter(|entry| entry.file_type().is_ok_and(|ft| ft.is_file()))
+ .count()
+ })
+ .unwrap_or(0),
+ };
let status = if super::hook_capture::capture_config_problem(repo_root_str).is_some() {
"marker invalid"
} else {
let policy = super::hook_capture::capture_policy(repo_root_str);
let probe_path = memory_dir.join("probe.md");
- let raw = serde_json::json!({
- "tool_name": "Read",
- "tool_input": { "file_path": probe_path.to_string_lossy() },
- });
+ let raw = synthetic_read_probe(harness, &probe_path);
let decision = policy.inspect(harness.agent_kind(), &raw, repo_root_str);
match decision.protocol().disposition() {
CaptureDisposition::Drop => "excluded",
@@ -1698,6 +1735,65 @@ mod tests {
.unwrap_or_else(|| panic!("expected a claude-code report; got {reports:?}"))
}
+ fn push_protobuf_varint(buf: &mut Vec<u8>, mut value: u64) {
+ while value >= 0x80 {
+ buf.push(((value & 0x7f) as u8) | 0x80);
+ value >>= 7;
+ }
+ buf.push(value as u8);
+ }
+
+ fn push_protobuf_bytes(buf: &mut Vec<u8>, field: u64, bytes: &[u8]) {
+ push_protobuf_varint(buf, (field << 3) | 2);
+ push_protobuf_varint(buf, bytes.len() as u64);
+ buf.extend_from_slice(bytes);
+ }
+
+ fn antigravity_metadata(uri: &str) -> Vec<u8> {
+ let mut nested = Vec::new();
+ push_protobuf_varint(&mut nested, 2 << 3);
+ push_protobuf_varint(&mut nested, 7);
+ push_protobuf_bytes(&mut nested, 1, uri.as_bytes());
+ push_protobuf_bytes(&mut nested, 4, b"fixture-metadata");
+
+ let mut outer = Vec::new();
+ push_protobuf_bytes(&mut outer, 3, b"unrelated");
+ push_protobuf_bytes(&mut outer, 1, &nested);
+ push_protobuf_varint(&mut outer, 5 << 3);
+ push_protobuf_varint(&mut outer, 1);
+ outer
+ }
+
+ fn antigravity_memory_fixture(home: &Path, cwd: &Path) -> PathBuf {
+ let root = home.join(".gemini/antigravity-cli/conversations");
+ std::fs::create_dir_all(&root).unwrap();
+ let path = root.join("11111111-2222-3333-4444-555555555555.db");
+ let connection = rusqlite::Connection::open(&path).unwrap();
+ connection
+ .execute(
+ "CREATE TABLE trajectory_metadata_blob (id text DEFAULT \"main\", data blob, PRIMARY KEY (id))",
+ [],
+ )
+ .unwrap();
+ let uri = format!("file://{}", cwd.display());
+ connection
+ .execute(
+ "INSERT INTO trajectory_metadata_blob (id, data) VALUES ('main', ?1)",
+ rusqlite::params![antigravity_metadata(&uri)],
+ )
+ .unwrap();
+ let knowledge = home.join(".gemini/antigravity-cli/knowledge");
+ std::fs::create_dir_all(&knowledge).unwrap();
+ knowledge
+ }
+
+ fn find_antigravity_report(reports: &[NativeMemoryReport]) -> &NativeMemoryReport {
+ reports
+ .iter()
+ .find(|r| r.agent == "antigravity-cli")
+ .unwrap_or_else(|| panic!("expected an antigravity-cli report; got {reports:?}"))
+ }
+
#[test]
fn native_memory_reports_is_not_excluded_without_a_marker() {
let home = tempfile::tempdir().unwrap();
@@ -1822,4 +1918,57 @@ mod tests {
let claude = find_claude_report(&reports);
assert_eq!(claude.file_count, 1);
}
+
+ #[test]
+ fn native_memory_reports_includes_antigravity_when_present() {
+ let home = tempfile::tempdir().unwrap();
+ let cwd = tempfile::tempdir().unwrap();
+ let knowledge = antigravity_memory_fixture(home.path(), cwd.path());
+ std::fs::write(knowledge.join("fact.md"), "x").unwrap();
+
+ let reports = native_memory_reports(home.path(), cwd.path());
+ let ag = find_antigravity_report(&reports);
+ assert_eq!(ag.status, "not excluded");
+ assert_eq!(ag.file_count, 1);
+ }
+
+ #[test]
+ fn native_memory_reports_antigravity_counts_nested_artifacts() {
+ let home = tempfile::tempdir().unwrap();
+ let cwd = tempfile::tempdir().unwrap();
+ let knowledge = antigravity_memory_fixture(home.path(), cwd.path());
+ let item_dir = knowledge.join("item-1/artifacts");
+ std::fs::create_dir_all(&item_dir).unwrap();
+ std::fs::write(item_dir.join("summary.md"), "summary").unwrap();
+ std::fs::write(knowledge.join("root-fact.md"), "fact").unwrap();
+
+ let reports = native_memory_reports(home.path(), cwd.path());
+ let ag = find_antigravity_report(&reports);
+ assert_eq!(ag.file_count, 2);
+ }
+
+ #[test]
+ fn native_memory_reports_antigravity_excluded_when_marker_covers_it() {
+ let home = tempfile::tempdir().unwrap();
+ let cwd = tempfile::tempdir().unwrap();
+ let knowledge = antigravity_memory_fixture(home.path(), cwd.path());
+ std::fs::write(knowledge.join("fact.md"), "x").unwrap();
+
+ let pattern = format!(
+ "{}/knowledge/**",
+ home.path()
+ .join(".gemini/antigravity-cli")
+ .to_string_lossy()
+ .replace('\\', "/")
+ );
+ std::fs::write(
+ cwd.path().join(".ai-memory.toml"),
+ format!("[capture]\nignore_paths = [\"{}\"]\n", pattern),
+ )
+ .unwrap();
+
+ let reports = native_memory_reports(home.path(), cwd.path());
+ let ag = find_antigravity_report(&reports);
+ assert_eq!(ag.status, "excluded");
+ }
}
diff --git a/crates/ai-memory-cli/src/commands/doctor/presentation.rs b/crates/ai-memory-cli/src/commands/doctor/presentation.rs
index 1f871a29..2cffce51 100644
--- a/crates/ai-memory-cli/src/commands/doctor/presentation.rs
+++ b/crates/ai-memory-cli/src/commands/doctor/presentation.rs
@@ -69,7 +69,7 @@ pub(super) fn render(report: &DoctorReport, terminal: &crate::terminal::Terminal
if !report.native_memory.is_empty() {
terminal.line(format_args!(
- "Note: a shell/PowerShell hook install (the Docker-wrapper default) does not \
+ "Note: a shell/PowerShell hook install does not \
enforce capture-policy v1 — \"excluded\" below only holds on a native hook \
install or a generated integration. Check the configured hook command; a dry-run \
`ai-memory install-hooks` reports the selected install path, not the active one.\n"
diff --git a/crates/ai-memory-workstream/src/transcript.rs b/crates/ai-memory-workstream/src/transcript.rs
index bf815b38..822dd481 100644
--- a/crates/ai-memory-workstream/src/transcript.rs
+++ b/crates/ai-memory-workstream/src/transcript.rs
@@ -946,6 +946,9 @@ pub async fn list_native_sessions(
/// file's own recorded `cwd` until one matches — and returns that file's
/// parent directory, which is correct on any platform by construction.
///
+/// Antigravity CLI keeps Knowledge Items under `<home>/.gemini/antigravity-cli/knowledge/`
+/// beside its `conversations/` directory.
+///
/// Callers should pass the checkout's **repository root**, not an arbitrary
/// subdirectory: Claude Code keys this store by repository root, so a
/// worktree or a subdirectory shares the root's `memory/` directory. This
@@ -964,7 +967,7 @@ pub fn native_memory_dir(
cwd: &Path,
session_dir: Option<&Path>,
) -> Option<PathBuf> {
- if harness != ManagedHarness::Claude {
+ if harness != ManagedHarness::Claude && harness != ManagedHarness::Antigravity {
return None;
}
let mut files = collect_session_files(harness, home, session_dir).ok()?;
@@ -978,7 +981,11 @@ pub fn native_memory_dir(
continue;
};
if same_path(&recorded_cwd, cwd) {
- let memory_dir = path.parent()?.join("memory");
+ let memory_dir = match harness {
+ ManagedHarness::Claude => path.parent()?.join("memory"),
+ ManagedHarness::Antigravity => path.parent()?.parent()?.join("knowledge"),
+ _ => return None,
+ };
return memory_dir.is_dir().then_some(memory_dir);
}
}
@@ -11040,6 +11047,63 @@ mod tests {
);
}
+ #[test]
+ fn native_memory_dir_finds_the_knowledge_directory_for_antigravity() {
+ let fixture = antigravity_fixture();
+ let knowledge = fixture
+ .temp
+ .path()
+ .join(".gemini/antigravity-cli/knowledge");
+ fs::create_dir_all(&knowledge).unwrap();
+ fs::write(knowledge.join("fact.md"), "hello").unwrap();
+
+ assert_eq!(
+ native_memory_dir(
+ ManagedHarness::Antigravity,
+ fixture.temp.path(),
+ &fixture.cwd,
+ None
+ ),
+ Some(knowledge)
+ );
+ }
+
+ #[test]
+ fn native_memory_dir_is_none_without_a_knowledge_directory_for_antigravity() {
+ let fixture = antigravity_fixture();
+ assert_eq!(
+ native_memory_dir(
+ ManagedHarness::Antigravity,
+ fixture.temp.path(),
+ &fixture.cwd,
+ None
+ ),
+ None
+ );
+ }
+
+ #[test]
+ fn native_memory_dir_is_none_when_no_antigravity_session_matches_this_cwd() {
+ let fixture = antigravity_fixture();
+ let knowledge = fixture
+ .temp
+ .path()
+ .join(".gemini/antigravity-cli/knowledge");
+ fs::create_dir_all(&knowledge).unwrap();
+ let other_cwd = fixture.temp.path().join("unrelated-checkout");
+ fs::create_dir_all(&other_cwd).unwrap();
+
+ assert_eq!(
+ native_memory_dir(
+ ManagedHarness::Antigravity,
+ fixture.temp.path(),
+ &other_cwd,
+ None
+ ),
+ None
+ );
+ }
+
#[test]
fn native_identity_adapter_preserves_exact_and_rejects_privacy_changes() {
for id in [