summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-05-24 03:42:43 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-05-24 03:42:43 +0800
commit3e30e13e7601884a8f3ec69a7899fd3e8d207e4f (patch)
treef44583c81867d2855f6b0cc01604043210d93c25
parent289aa96f02f99bb724013e473725760a86ba6190 (diff)
Add optional --about filter to explore and dumpall commands
-rw-r--r--builtin/PROMPT.md8
-rw-r--r--src/mem_mgr.rs23
2 files changed, 25 insertions, 6 deletions
diff --git a/builtin/PROMPT.md b/builtin/PROMPT.md
index 6a4cdef..5343b4f 100644
--- a/builtin/PROMPT.md
+++ b/builtin/PROMPT.md
@@ -39,7 +39,7 @@ Always decide the language of your reply based on the language the user uses to
## Explore (view all memory entries)
```
-memm explore
+memm explore [--about <FILTER>]
```
This tool outputs a list of entry titles. You can **read, rewrite, remember, forget, or dumpall** specific memories based on the titles in the list.
@@ -95,10 +95,12 @@ This tool **completely replaces** the content of the memory entry with the new *
## DumpAll (dump all memory entries with their full content)
```
-memm dumpall
+memm dumpall [--about <FILTER>]
```
-This tool outputs **all memory entries** with their **full content** in a structured format, including each entry's title and content. This is useful when you need to see everything at once, e.g., when the chat session just started to load all memories into context.
+**FILTER** (optional): A fuzzy filter string to narrow down results. Only entries whose title matches the filter (case-insensitive, alphanumeric-only comparison) will be returned.
+
+This tool outputs **all memory entries** (or those matching the optional filter) with their **full content** in a structured format, including each entry's title and content. This is useful when you need to see everything at once, e.g., when the chat session just started to load all memories into context.
**Important:** When you first enter a new chat session, you **must** use `memm dumpall` to load all past memories into your context.
diff --git a/src/mem_mgr.rs b/src/mem_mgr.rs
index 8b9d950..c6e442e 100644
--- a/src/mem_mgr.rs
+++ b/src/mem_mgr.rs
@@ -50,8 +50,9 @@ pub fn handle_read(args: EntryRead, constants: &Constants) -> Next {
}
#[chain]
-pub fn handle_dumpall(_p: EntryDumpAll, constants: &Constants) -> Next {
- dumpall(constants).to_render()
+pub fn handle_dumpall(args: EntryDumpAll, constants: &Constants) -> Next {
+ let about = args.pick::<String>("--about").unpack();
+ dumpall(constants, about).to_render()
}
#[derive(Serialize, Groupped)]
@@ -214,7 +215,7 @@ fn forget(constants: &Constants, title: String) -> ResultForgotten {
}
}
-fn dumpall(constants: &Constants) -> ResultDumpAll {
+fn dumpall(constants: &Constants, about: String) -> ResultDumpAll {
let store_root = &constants.store_root;
let mut entries = Vec::new();
if let Ok(dir_entries) = std::fs::read_dir(store_root) {
@@ -225,6 +226,22 @@ fn dumpall(constants: &Constants) -> ResultDumpAll {
if let Some(stem) = path.file_stem() {
let title = stem.to_string_lossy().to_string();
let content = std::fs::read_to_string(&path).unwrap_or_default();
+ // If about is provided and not empty, do fuzzy matching on lowercase alphanumeric
+ if !about.is_empty() {
+ let filter: String = about
+ .chars()
+ .filter(|c| c.is_alphanumeric())
+ .collect::<String>()
+ .to_lowercase();
+ let title_clean: String = title
+ .chars()
+ .filter(|c| c.is_alphanumeric())
+ .collect::<String>()
+ .to_lowercase();
+ if !title_clean.contains(&filter) {
+ continue;
+ }
+ }
entries.push(DumpEntry { title, content });
}
}