search_notes
Find relevant notes, decisions, and context from your knowledge base to understand project background, prior choices, and architecture details.
Instructions
Search the user's knowledge base for relevant notes, decisions, and context. Use this when you need background on a topic, want to find prior decisions, or need to understand project architecture.
Args: query: Natural language search query (e.g. 'authentication approach', 'database schema decisions') top_k: Number of results (default 10, max 100)
Returns ranked list of matching notes with titles, paths, and text snippets.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Natural language search query | |
| top_k | Yes | Number of results (default 10, max 100) |
Implementation Reference
- The implementation of the search logic (called `same_search` in this file) invokes the `same search` command to interact with the vault and process the results.
def same_search(vault_dir: str, query: str, top_k: int = SEARCH_TOP_K) -> list[str]: """ Run `same search` and return the top-k result texts. Returns a list of result strings. """ try: result = subprocess.run( [SAME_BIN, "search", "--json", "--top-k", str(top_k), query], cwd=vault_dir, capture_output=True, text=True, timeout=QUESTION_TIMEOUT, ) except subprocess.TimeoutExpired: log(f" TIMEOUT: same search for '{query[:50]}...'") return [] if result.returncode != 0: return [] # Parse JSON output try: data = json.loads(result.stdout) except json.JSONDecodeError: # Fallback: return raw stdout lines return [line.strip() for line in result.stdout.strip().split("\n") if line.strip()] # Extract text from results — adapt to SAME's JSON format texts = [] if isinstance(data, list): for item in data: if isinstance(item, dict): # SAME uses "snippet" for retrieved text text = item.get("snippet") or item.get("content") or item.get("text") or item.get("body") or "" if text: texts.append(text) elif isinstance(item, str): texts.append(item) elif isinstance(data, dict): # Might be wrapped in a results key results = data.get("results") or data.get("matches") or data.get("notes") or [] for item in results: if isinstance(item, dict): text = item.get("snippet") or item.get("content") or item.get("text") or item.get("body") or "" if text: texts.append(text) elif isinstance(item, str): texts.append(item) return texts[:top_k]