SuperAPI AI Directory

local-search

General & other

View repository

Updated 10-16 00:04

About this skill

Local File Search

Search file contents and file names on the user's computer.

Use Cases

  • The user says "Help me find the report I wrote last time" or "Search for files containing XXX"
  • The user needs to find a specific file but does not remember where it is
  • A reference file needs to be located during task execution

Search Methods

Method 1: knowledge_search tool (content search, preferred)

Search document contents in the indexed knowledge base. Supports FTS5 full-text search and semantic search.

工具名: knowledge_search

Parameters: query: Search query (natural language), required limit: Number of results to return, default 5 file_type: Filter by file type (e.g. .md, .txt, .pdf), optional


<example>
<query>帮我找一下之前写的季度总结</query>
<action>
调用 knowledge_search,参数:{"query": "季度总结"}
</action>
<reasoning>用户要搜索文档内容,knowledge_search 覆盖已索引文件,优先使用</reasoning>
</example>

<example>
<query>搜一下包含"预算审批"的 PDF 文件</query>
<action>
调用 knowledge_search,参数:{"query": "预算审批", "file_type": ".pdf"}
</action>
<reasoning>有明确的文件类型过滤需求,使用 file_type 参数</reasoning>
</example>

<example>
<query>我上传的产品文档里有没有提到竞品分析?</query>
<action>
调用 knowledge_search,参数:{"query": "竞品分析"}
</action>
<reasoning>搜索已索引文档中的特定内容</reasoning>
</example>

### 方式 2:mdfind(文件名搜索,补充)

knowledge_search 无结果时,用 macOS Spotlight 按文件名或元数据搜索。

```bash
# 按文件名搜索
mdfind -name "报告"

# 限定目录
mdfind -onlyin ~/Documents "预算"

# 限定文件类型
mdfind "kind:pdf 合同"
mdfind "kind:word 报告"

Search Strategy

  1. Prefer knowledge_search: Covers indexed knowledge base files, supports content search and semantic matching
  2. Use mdfind when knowledge_search returns no results: Searches by file name or metadata, with broader coverage
  3. When neither returns results: Inform the user and ask whether the target directory should be added to the knowledge base index

Output Specifications

  • Display search results, including file paths and summary snippets
  • Use ~ to abbreviate the user directory in paths
  • Inform the user of the total number of results found
  • When there are too many results, ask the user whether further filtering is needed