/** * search-tools extension — tier-aware activation of pi's built-in search tools. * * pi registers seven built-in tools but activates only read/bash/edit/write * (findings §2); grep/find/ls sit in the registry and are never activated. * Claude Code ships no Grep/Glob/LS on any tier (bash covers search — Haiku * included), so frontier/workhorse/cheap stay lean; only One Code's sub-Haiku * `tiny` tier, whose prompt steers to "the search tools", gets them in the * request. Tier resolution is the same call the system-prompt extension makes, * so prompt text and tool surface stay in step, including on a mid-session model * change. */ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; import { resolveModelTier } from "../lib/model-tier.ts"; import { withSearchTools } from "./tools.ts"; export default function searchToolsExtension(pi: ExtensionAPI) { const apply = (model: Parameters[0]) => { const tier = resolveModelTier(model); const active = pi.getActiveTools(); const next = withSearchTools(active, tier); if (next.join("") !== active.join("")) pi.setActiveTools(next); }; pi.on("session_start", (_event, ctx) => apply(ctx.model)); pi.on("model_select", (event) => apply(event.model)); }