跳到正文
Hacker News (official RSS)·· 2 小時前精選AI 評分77

Pensieve 本地索引降低工具呼叫與令牌使用

Local Indexing to reduce tool calling and token usage

AI 導讀

Pensieve 是一個在 Mac 上執行的本機索引工具,能為 AI 代理提供精準上下文,減少工具呼叫與成本。

\n- 功能:搜尋本機檔案、倉儲與代理對話,返回關鍵段落與檔案位置,支援意義搜尋與精確字詞。

推薦理由

Pensieve 透過本機索引,降低代理工具呼叫與 API 成本,並以 0.1~0.2 秒快速定位關鍵程式碼,對於需要高效 AI 開發流程的工程師來說,具備顯著實務價值。

正文 · AI 翻譯

Pensieve for Mac

Supercharges you
and your agents.

Search your files, repos and agent sessions, locally, and give your agents the best context for the job. One search points them to the few passages that matter, instead of grepping the whole disk. Fewer tool calls, lower cost.

Install with your agent

See how it works

Apple Silicon · macOS 14 or later · free and open source

Connects to the agents you already use

  • Claude Code
  • Codex
  • Cursor
  • Gemini CLI
  • Windsurf
  • Claude Desktop
  • VS Code
  • any MCP client

Search everything, locally

One search. Every file, repo and session.

Press Control+Shift for a glass panel over your documents, folders, git repositories and conversations with coding agents. Search by meaning or by the exact words. Pick a result, tap Control, and choose what to do with it without touching the mouse.

"retry" payments -draft

Exact "retry"   Meaning payments   Without draft

Code

payments/retry.pyacme-app/payments · max_retry_attempts = 5

exact

Incident review.md~/Documents/Ops · card declines, retry with backoff

exact

ReceiptsFolder in ~/Downloads

Refactor the auth flowCodex · acme-app · Oct 2

Open↩

Show in Finder⌘↩

Show on map⌥↩

Copy path⌘C

pricing model

By meaning

Plain words find what you meant, even when the file never uses them.

"rate limit"

Exact words

Quotes match the phrase exactly. Mix both to rank exact hits by meaning.

-draft

Leave things out

A minus sign excludes a word or a quoted phrase.

kind:code ext:pdf

Narrow it down

Filter to files, code or sessions, a file type, or a folder or repo with in:.

Superpowers for your agents

The right context. Not the whole disk.

Agents are only as good as the context they're given. Connected over MCP, your coding agent asks Pensieve one question and gets back the few passages that matter, with file and line. It starts on the right code in fewer tool calls.

Without Pensieve grep and read

› Why do card retries stop after a decline?
● Grep "retry" in acme-app   212 matches
● Read payments/retry.py
● Read payments/gateway.py
● Read billing/invoices.py
● Read tests/test_payments.py
  … 36 more files
  Still looking for the backoff rule…

Tool calls1 grep · 40 reads and counting

With Pensieve one search

› Why do card retries stop after a decline?
● pensieve · search "card retry after decline"
  payments/retry.py:42      stop on hard_decline
  payments/gateway.py:118   decline codes
  Incident review.md        why we changed it
● pensieve · read payments/retry.py:42
Hard declines skip the retry queue.
Maya Rivera owns this; see the Mar 4 review.

Tool calls1 search · 1 read

Illustrative example. In the benchmark below, agents with Pensieve averaged 2.0 tool calls per lookup against 3.4 with grep, and answered after a single call in 82 of 144 runs.

~ $ pensieve integrate recommended
claude-mcp: on
codex-mcp: on
cursor-mcp: on
claude: on          # "search before you grep" in ~/.claude/CLAUDE.md
pensieve-search: on
claude-hook: on
claude-repo-check: on
Agents load MCP servers when they start: restart any that are open to give them Pensieve.

Scoped to the job

An agent started in a repo sees that repo, its worktrees and its sessions. Name a scope to give it a few repos and a folder of specs.

Exact or by meaning

Agents use the same search you do: by meaning, by the exact identifier, or both, across code, docs and past sessions.

Works with your agent

Claude Code, Codex, Cursor or any MCP client, over stdio with pensieve mcp or over HTTP. pensieve integrate connects the agents on your Mac and adds a “search before you grep” block and skills, including optional ones that point you to teammates who know the code.

Measured, not promised

Fewer searches. Right file first.

We gave Claude Code the same code-finding tasks with and without Pensieve: held-out tasks across real repos from 500 to 35,000 files, asked five ways, from plain descriptions to exact names and error messages. With Pensieve it finds more of them, with fewer tool calls, and costs less per lookup in every repo. Each search takes 0.1 to 0.2 seconds.

131 / 144執行次數:使用 Pensieve 找到正確檔案 131 / 144 次,僅使用 grep 為 123 / 144 次

43% 更少每次查詢的工具呼叫次數:2.0 次,而非 3.4 次

18% 更便宜每次查詢:$0.041,而非 $0.050,且在四個倉庫皆更便宜

21% 更快每次查詢:8.6 秒,而非 10.9 秒

正確檔案,首個結果

單一搜尋,未使用任何代理前:答案為首位結果的頻率。

一次 grepPensieve 搜尋

代理程式每次程式碼查詢成本

Claude Sonnet 在 Claude Code 中,於四個實際倉庫測量。Pensieve 在每個倉庫的成本皆較低,且在最大倉庫中節省最多。

Grep、Glob 與 Read使用 Pensieve

方法:Claude Sonnet 以無頭模式透過 Claude Code 執行。任務由程式碼生成,並以找到的檔案作為評分依據。「使用 Pensieve」是預設代理工具組加上來自 pensieve integrate 的說明區塊,使用 Pensieve 0.5.6 測量。兩套設定皆在四個倉庫中執行相同的 72 個留存任務(504、1,783、2,383 和 34,847 個檔案),每個任務執行兩次,並在同一批次完成,因為成本取決於當時 Claude 的提示快取。這些任務從未用於調校 Pensieve。成本為 Claude Code 報告的 API 成本,按建議售價計算。Pensieve 使用的 tokens 少 16%。「正確檔案,首個結果」圖表使用相同的留存任務:單一 grep 在精確錯誤訊息上勝出,Pensieve 在其他情況下勝出。基準指令碼為開源,位於 bench/;在您自己的倉庫上執行它們。

知道該詢問誰

檢視誰擁有什麼

將每個倉庫視為地圖,對每行使用 git blame。詢問任何主題,即可得到擁有最多領域知識的人,以及每位同事最近在做什麼。最快的答案往往是對話。

從 blame 獲得擁有權

誰寫了每個區域,按今天仍在的行數加權。

領域知識

詢問主題而非檔案,並獲得編寫相關程式碼最多的人。

團隊活動

每位同事在過去 90 天內交付的內容,以及您尚未探索的與您工作相鄰的區域。

找出知識缺口

瞭解知識留下的地方。

當編寫程式碼某部分的人不再活躍,該知識即處於風險中。Pensieve 會標記這些區域,顯示仍知悉的人數極少,以及今天誰最擅長。

acme-app / billing/tax

1 位活躍專家

2,140 行 · 最後重大變更 7 個月前

此處未活躍 · 78%Priya Nair · 14%其他人 · 8%

DK

Daniel Kim自三月以來此處未活躍

58%

LS

Lena Schultz自去年以來此處未活躍

20%

PN

Priya Nair本月活躍 · 今日最懂

14%

建議:在更改稅率前與 Priya 配對,並於 vat.py 中記錄四捨五入邏輯。

一目瞭然的 Bus factor

對於倉庫的每個區域:有多少程式碼由仍活躍的人撰寫,以及有多少人。

誰仍然知道

該區域中活躍且行數最多的人,讓您在更改前知道該請誰協助。

規劃交接

在事故發生前發現缺口。將代理指向該區域以草擬缺失檔案。

使用虛構名稱與數字的範例。

始終最新

編輯檔案。數秒後搜尋。

Pensieve 監控您的資料夾、倉庫和代理會話,並重新索引變更內容。未提交的編輯會被計算,每個工作樹都按分支追蹤,確保代理永不使用過時的上下文。

payments/retry.pyacme-app 中未提交的變更

現在

New worktree: fix-backoff與主分支不同的檔案,並以其分支標記

12 秒前

Q3 planning.pdf儲存至 ~/Documents/Planning

1 分鐘前

Price the annual plan correctly在執行中的 Claude Code 會話中新增轉折

2 分鐘前

設計為私有

你的工作留在你的 Mac 上。

索引與搜尋在本機執行。你決定什麼會被索引,AI 完全可選。

在本機執行

在裝置上執行的嵌入模型與本機索引於 ~/.pensieve。其伺服器僅回應此 Mac,非你的網路或其他網站。無帳號,無雲端服務。

關閉任何來源

代理、資料夾、倉庫與應用各有一個開關。關閉其中一個會移除其已索引的內容。

跳過機密

密碼管理器匯出、金鑰、.env 檔案與憑證永不被索引。

AI 如你願意

摘要與洞察為可選。選擇誰撰寫,或關閉:

內建 Qwen 3.5 9B Local

LM Studio 或本機伺服器 Local

Claude Code 或 Codex Cloud

關閉 Local

取得 Pensieve。

免費且開源。你的編碼代理負責設定。

詢問你的編碼代理。

將此貼入 Claude Code、Codex、Cursor、Gemini CLI、Qwen Code、Windsurf 或 VS Code。

在我的 Mac 上安裝 Pensieve,執行 sh -c "$(curl -fsSL https://tedhaley.ca/pensieve/install.sh)",然後執行 pensieve integrate recommended。接著執行 pensieve setup,顯示它找到什麼,詢問我哪些來源要索引,並以我的選擇執行 pensieve setup。開啟 Pensieve 應用程式並告訴我何時準備好。

  1. 1貼上提示將其貼入你使用的任何編碼代理。
  2. 2你的代理安裝它安裝應用程式,然後為你 Mac 上的每個代理安裝 Pensieve。
  3. 3選擇索引內容你的代理會詢問。未選擇前不會索引任何內容。
  4. 4按住 Control 與 Shift在索引執行時搜尋。它會消耗大量能量,請接上電源。

版本 0.5.9 · Apple Silicon · macOS 14 或更高

問題。

Pensieve 搜尋什麼?

你的檔案與資料夾(Documents、Desktop、Downloads 以及任何你新增的資料夾)、你的 git 倉庫(包含未提交的變更與工作樹)、以及你的 Claude Code、Codex 與 Qwen Code 會話。Obsidian 錢包也包含在內,並且可選擇 Apple Notes。所有內容均在你的 Mac 上被索引與搜尋。

Pensieve 如何協助我的代理?

若無此功能,編碼代理通常會對倉庫進行 grep,並閱讀大量完整檔案以尋找關鍵資訊,每閱讀一個檔案都會產生 token 費用。使用 Pensieve 透過 MCP 連線,代理只需提出一個問題,即可獲得最相關的段落及其檔案與行號,從而以更少的工具呼叫直接定位正確程式碼。在我們的基準測試中,這使每次查詢成本降低 18%,速度提升 21%;詳見上方測試結果。

Pensieve 是否使 Claude Code 更便宜?

在我們的基準測試中,Claude Code 結合 Pensieve 在 144 次執行中找到正確檔案 131 次,僅使用 grep 時為 123 次,工具呼叫減少 43%。每次查詢的總成本降低 18%,在四個倉庫中從 504 到 34,847 個檔案,單次成本降低 6–28%。基準指令碼為開源,您可以在自己的程式碼上執行。

如何讓我的代理使用 Pensieve 而非 grep?

代理程式以習慣進行 grep。安裝提示會執行 pensieve integrate recommended,它會在 Claude Code、Codex 與 Gemini CLI 的說明檔案中新增一個簡短的「在 grep 前先搜尋」區塊,並加入搜尋技能與兩個 Claude Code 的掛鉤。你也可以在 Settings → Agents 開關這些功能。使用此功能,代理程式在我們最新基準測試的 144 次執行中皆使用 Pensieve。

哪些代理程式可以與 Pensieve 一同使用?

任何 MCP 客戶端。pensieve integrate recommended 為你連線 Claude Code、Codex、Cursor、Gemini CLI、Windsurf、Claude Desktop 與 VS Code。其他代理程式可透過 stdio 或 HTTP 使用 pensieve mcp。可選技能還會建議哪些同事熟悉某個領域,並協助規劃新程式碼以配合現有程式。

它如何找出知識缺口?

Pensieve 會閱讀每個 repo 內各區域的 git blame 與最近的提交歷史。若某區域大多行程式碼是由近期未提交的開發者所寫,該區域將被標記,並顯示有多少活躍開發者瞭解此區域,以及其中誰是最熟悉者。

有什麼東西會離開我的 Mac 嗎?

不會。檔案、程式碼與工作階段都不會離開。索引與搜尋皆在你的 Mac 上執行。Pensieve 只會下載其模型並檢查 GitHub 的更新,你可選擇關閉。唯一例外是若你選擇 Claude Code 或 Codex 產生可選的 AI 洞見;這些會被標示為 Cloud。內建模型、類似 LM Studio 的本地伺服器,或完全不使用 AI,皆能保持所有資料本地。

我需要 AI 模型嗎?

不需要。搜尋、代理程式上下文、擁有權與知識缺口均可在無 AI 模型的情況下運作。AI 洞見是可選的:你可選擇內建的 Qwen 3.5 9B、LM Studio、Claude Code、Codex,或直接不啟用。

Pensieve 是免費嗎?

是的。它在 MIT 授權下免費且開源。程式碼可在 GitHub 找到。

為什麼 macOS 會在開啟前詢問?

此應用程式尚未經 Apple notarization。若 macOS 阻擋,請開啟 System Settings → Privacy & Security,點選 Open Anyway。你只需執行一次。

它能在 Intel Mac 或 Linux 上運作嗎?

此應用程式需要 Apple Silicon。於 Linux 與 Intel Mac 上,會安裝相同的後端與瀏覽器視覺化工具。若 Intel Mac 安裝了 Xcode 命令列工具,也會取得搜尋面板。

如何解除安裝?

先執行 pensieve integrate all --remove 以斷開你的代理程式。接著退出 Pensieve,將其拖到垃圾桶,並刪除 ~/.pensieve、~/.local/share/uv/tools/pensieve 與 ~/.local/bin/pensieve。其模型位於 ~/.cache/huggingface。

來源:Hacker News (official RSS) · tedhaley.ca