From 22f482d6bbd0aa183d28921685ee4e071005ac24 Mon Sep 17 00:00:00 2001 From: Prasanna721 Date: Wed, 20 May 2026 01:43:19 -0700 Subject: [PATCH 1/3] agent_hint: split render_block per-agent --- crates/smfs-core/src/agent_hint.rs | 56 +++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/crates/smfs-core/src/agent_hint.rs b/crates/smfs-core/src/agent_hint.rs index 4132102..0cbdfa8 100644 --- a/crates/smfs-core/src/agent_hint.rs +++ b/crates/smfs-core/src/agent_hint.rs @@ -82,7 +82,39 @@ fn home_dir() -> Option { directories::BaseDirs::new().map(|b| b.home_dir().to_path_buf()) } -fn render_block(tag: &str, mount_path: &Path) -> String { +/// Dispatcher. Claude gets `render_claude_block`; Codex and Gemini share +/// `render_default_block`. The two bodies are nearly identical — only the +/// opener differs, see `render_default_block`. +fn render_block(tag: &str, mount_path: &Path, agent: &str) -> String { + match agent { + "Claude Code" => render_claude_block(tag, mount_path), + _ => render_default_block(tag, mount_path), + } +} + +fn render_claude_block(tag: &str, mount_path: &Path) -> String { + let begin = begin_marker(tag); + let end = end_marker(tag); + let path_str = mount_path.display(); + format!( + "{begin}\n\ + \n\ + The directory `{path_str}/` is a Supermemory mount with semantic search.\n\ + For semantic search use: smfs grep \"query\" (or smfs grep \"query\" path/\n\ + to scope to a folder or single file). It returns\n\ + :-:. From there, read just the line range\n\ + using the Read tool with offset and limit. The chunk text is verbatim\n\ + from the file, so the Grep tool with any fragment of it pulls every\n\ + related hit in the corpus.\n\ + For a quick high-level overview before searching, read\n\ + `{path_str}/profile.md` — it's a reserved virtual file at the mount\n\ + root with a summary of what this container holds. Files outside this\n\ + directory behave normally — this rule is scoped to that path only.\n\ + {end}\n" + ) +} + +fn render_default_block(tag: &str, mount_path: &Path) -> String { let begin = begin_marker(tag); let end = end_marker(tag); let path_str = mount_path.display(); @@ -90,16 +122,16 @@ fn render_block(tag: &str, mount_path: &Path) -> String { "{begin}\n\ \n\ The directory `{path_str}/` is a Supermemory mount with semantic search.\n\ - When searching inside this directory, use:\n\ - \n\ - \u{0020} smfs grep \"\" {path_str}/\n\ - \n\ - instead of grep, rg, find, or your built-in search tool. It returns\n\ - semantically relevant excerpts via a vector index. For a quick high-\n\ - level overview before searching, read `{path_str}/profile.md` — it's\n\ - a reserved virtual file at the mount root with a summary of what\n\ - this container holds. Files outside this directory behave normally —\n\ - this rule is scoped to that path only.\n\ + For semantic search use: smfs grep \"query\" (or smfs grep \"query\" path/\n\ + to scope to a folder or single file). It returns\n\ + :-:. From there, read just the line range\n\ + using the Read tool with offset and limit. The chunk text is verbatim\n\ + from the file, so the Grep tool with any fragment of it pulls every\n\ + related hit in the corpus.\n\ + For a quick high-level overview before searching, read\n\ + `{path_str}/profile.md` — it's a reserved virtual file at the mount\n\ + root with a summary of what this container holds. Files outside this\n\ + directory behave normally — this rule is scoped to that path only.\n\ {end}\n" ) } @@ -107,9 +139,9 @@ fn render_block(tag: &str, mount_path: &Path) -> String { /// Install the hint into every detected agent file. Idempotent: an existing /// block for `tag` is replaced; otherwise the new block is appended. pub fn install(tag: &str, mount_path: &Path) -> Result> { - let block = render_block(tag, mount_path); let mut written = Vec::new(); for target in discover_targets() { + let block = render_block(tag, mount_path, target.agent); let Some(parent) = target.path.parent() else { continue; }; From 047136166fd0298c7385dc1ad9aa8af3f0fe2db4 Mon Sep 17 00:00:00 2001 From: Prasanna721 Date: Wed, 20 May 2026 01:44:56 -0700 Subject: [PATCH 2/3] agent_hint: nudge codex/gemini opener away from filename-grep --- crates/smfs-core/src/agent_hint.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/smfs-core/src/agent_hint.rs b/crates/smfs-core/src/agent_hint.rs index 0cbdfa8..178b810 100644 --- a/crates/smfs-core/src/agent_hint.rs +++ b/crates/smfs-core/src/agent_hint.rs @@ -121,7 +121,7 @@ fn render_default_block(tag: &str, mount_path: &Path) -> String { format!( "{begin}\n\ \n\ - The directory `{path_str}/` is a Supermemory mount with semantic search.\n\ + The directory `{path_str}/` is searchable by meaning, not just filename.\n\ For semantic search use: smfs grep \"query\" (or smfs grep \"query\" path/\n\ to scope to a folder or single file). It returns\n\ :-:. From there, read just the line range\n\ From db1aa26534d193c8ef452a3aa01be659e061d00c Mon Sep 17 00:00:00 2001 From: Prasanna721 Date: Wed, 20 May 2026 01:45:59 -0700 Subject: [PATCH 3/3] smfs grep: collapse banner into single line --- crates/smfs/src/cmd/grep.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/smfs/src/cmd/grep.rs b/crates/smfs/src/cmd/grep.rs index c6b0153..4812e62 100644 --- a/crates/smfs/src/cmd/grep.rs +++ b/crates/smfs/src/cmd/grep.rs @@ -230,10 +230,7 @@ pub async fn run(args: Args) -> Result<()> { eprintln!("# searches by meaning across files in this container. usage:"); eprintln!("# grep \"natural language query\" search all files"); eprintln!("# grep \"query\" path/to/dir/ search within directory"); - eprintln!("# output: :-:"); - eprintln!( - "# chunk text is verbatim from the file. extract by the line range. never read or cat whole files." - ); + eprintln!("# output: :-: (chunk text is verbatim from the file)"); eprintln!(); let mut file_cache: HashMap> = HashMap::new();