Communitygithub.com

lovstudio/search-file-skill

從 AI 對話回憶中追蹤本地檔案,提供 Session 證據與耐久度排序。

search-file-skill 是什麼?

這個技能能將使用者記憶中的 AI 對話主題、片段或 Session ID 還原成可驗證的本地檔案候選清單。它會區分專案歸檔、下載目錄、AI 生成快取與臨時目錄,並優先回傳仍存在且更耐久的副本。支援 ChatGPT、Claude 與 Codex 等常見 AI 工具。運作方式是先用 ripgrep 預先篩選對話記錄,再解析使用者與助手的訊息及其工具呼叫中的本地路徑,最後按檔案存在狀態、分數與耐久度排序結果。無需網路或第三方套件,僅依賴 Python 3.9+ 標準函式庫與選用的 ripgrep。

相容平台✓Claude Code✓Codex CLI~Cursor
npx skills add lovstudio/search-file-skill

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

lov-search-file — 從 AI 對話追到本地檔案

把使用者記得的對話主題、片段或 Session ID 還原為可驗證的本地檔案候選。結果會區分 專案歸檔、下載目錄、AI 生成快取與臨時目錄,優先回傳仍然存在且更耐久的副本。

Triggers

Activate when

  • 「找一下之前 Codex 給我 P 頭像的圖片儲存位置。」
  • 「上次 AI 生成的 PDF / PPT / 壓縮包在哪?」
  • 「從那次對話裡把最終交付檔案找出來。」
  • "Find the image/file from an earlier Codex, ChatGPT, or Claude conversation."

Do not activate when

  • 只想回憶之前討論或決定了什麼,不需要檔案路徑 → lov-search-chat
  • 只想定位一個原始碼倉庫或專案目錄 → lov-search-project
  • 已知當前目錄和檔名,只需普通原始碼搜尋 → rg / find
  • 檔案只存在於網碟或遠端聊天附件,本機無副本 → 使用對應連接器或雲端搜尋

User Profile (cross-session)

Every generated Skill is connected to the shared user-profile/v1 contract in skill.yaml. Read the shared user, brand, workspace, preferences, and this Skill's skills.<skill_id> namespace at the start of every run. Keep the source portable: resolved personal values belong in the shared profile, never here.

When the user directly states a durable preference or brand fact, persist it through scripts/profile_store.py and report the saved profile path. Put Skill-specific values under records.<field>; use brand.<field> or user.<field> for shared values. Do not persist inferred secrets or credentials. See references/user-profile.md for the complete contract.

Skill Group Composition

Read references/skill-composition.md before deciding whether to invoke or extend any adjacent capability. The record distinguishes optional upstream and downstream handoffs from embedded Kit modules. Do not silently depend on a sibling Skill that is not shipped with this source.

Workflow (MANDATORY)

You MUST follow these steps in order.

Step 0: Resolve skill root, dependencies, and runtime context

  • Use SKILL_DIR if the environment provides it.
  • Otherwise infer the installed skill directory from the current skill context.
  • Verify every required local module, reference, script, and asset before work.
  • 必須確認 scripts/find_ai_file.py、scripts/profile_store.py、 references/skill-composition.md 均存在。
  • If a required resource is missing, name its expected relative path and stop before producing a partial result.

When running scripts manually:

export SKILL_DIR="/path/to/lov-search-file"

Resolve context.profile on every invocation. The precedence is current request, project context, Skill-specific profile records, shared preferences, shared brand/user profile, then safe defaults. A direct user statement about a durable preference or brand fact should be saved with scripts/profile_store.py record using --confirm, followed by a concise saved-path report.

Step 1: Understand the requested outcome

  • 提取使用者仍記得的線索:對話主題或原話、AI 產品、檔案類型、大致日期、專案名、 檔案名稱片段與 Session ID。現有線索足夠時直接搜尋,不先追問。
  • 區分使用者要找的是 AI 的最終輸出、原始輸入附件,還是所有相關副本;預設最終輸出 優先,但保留原始輸入作為低分候選。
  • 自動從查詢推斷 image、document、audio、video、archive 等類型;使用者已 明確類型時以目前請求為準。

Step 1.5: Analyze nearby Skills before implementation

  • 先讀 references/skill-composition.md。lov-search-chat 可以提供 Session ID、 message ID 或原文片段作為可選上游,但不是執行時期依賴。
  • lov-search-project 回傳專案目錄,不回傳專案裡的具體對話交付檔案;不要把兩個 Skill 合併,也不要用專案名命中冒充檔案證據。

Step 2: Execute the workflow

  1. 若主機提供任務/對話搜尋能力,先唯讀查詢匹配的歷史任務,取得更準確的標題、 Session ID 或原話;ChatGPT 桌面端的加密資料不可由本地腳本直接解密。沒有該能力 時直接進入本地 transcript 搜尋,不把連接器當硬依賴。

  2. 執行確定性 CLI。預設自動推斷檔案類型,並輸出 JSON 供 Agent 排序解讀:

python3 "$SKILL_DIR/scripts/find_ai_file.py" "<記得的對話或檔案線索>" --json
  1. 已知 Session ID 時強約束搜尋;使用者還給了自訂對話目錄或檔案根時重複傳參:
python3 "$SKILL_DIR/scripts/find_ai_file.py" "<線索>" \
  --session-id '<session-uuid>' \
  --transcript-root '<transcript-root>' \
  --root '<file-root>' --json
  1. CLI 先用 ripgrep 預篩 transcript,再只解析使用者/助手訊息及工具呼叫裡的本地路徑; 它不會把 developer/system 文字當成對話證據。命中的 session 會繼續關聯 $CODEX_HOME/generated_images/<session-id> 與該 session 工作目錄的 output/、 outputs/。增量索引存於使用者快取目錄,權限為 0600;傳 --no-cache 可停用。

  2. 按 exists、score 與 durability 解釋結果:

    • project-output / documents:優先作為長期副本;
    • downloads:使用者可直接存取的交付副本;
    • ai-cache:可追溯生成來源,但不視作唯一長期歸檔;
    • temporary:可能隨時消失,不能作為唯一結論。
  3. 結果為空時,用同義詞或更準確的原話重試;需要查看已在對話中提及但已刪除的 路徑時加 --include-missing。仍為空就明確說未找到,不編造路徑。

Step 3: Validate the deliverable

  • 對最終候選再次 stat,確認檔案在本輪仍存在,並報告大小、修改時間與證據 session。
  • 至少給出一個推薦路徑;同一製品有多個副本時按耐久度說明主副本與快取副本。
  • 不移動、複製、刪除或上傳任何命中檔案,除非使用者另行明確要求。
  • 運行 python3 scripts/validate_skill.py . 與聚焦回歸測試,驗證可信度卡、真實案例 和本地安裝鏈。

Dependencies

  • Python 3.9+(僅標準函式庫)
  • ripgrep(推薦,用於快速預篩;缺失時回退到受上限保護的 transcript 掃描)
  • 不需要網路、憑證或第三方 Python 套件

相關技能