fix(engine): register grep/find/ls alongside read/bash/edit/write for coding sessions

pi-coding-agent 0.70's createCodingTools preset only includes read/bash/edit/write,
but pi-claude-cli's tool-mapping translates Claude's Glob→find and Grep→grep.
Triage sessions running through Claude CLI hit "Tool find not found" the moment
the model called Glob and looped on the error.

Compose the built-in set explicitly so every tool referenced by tool-mapping.ts
is registered. Read-only sessions also gain ls (was silently dropped earlier
when readonly was redefined upstream).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-25 16:34:31 -07:00
parent 359e08c45c
commit 73ff095ccc
3 changed files with 66 additions and 2 deletions

View File

@@ -15,9 +15,16 @@ import { basename, dirname, join, relative, isAbsolute, resolve } from "node:pat
const execAsync = promisify(exec);
import {
createAgentSession,
createBashTool,
createCodingTools,
createEditTool,
createExtensionRuntime,
createFindTool,
createGrepTool,
createLsTool,
createReadOnlyTools,
createReadTool,
createWriteTool,
DefaultResourceLoader,
DefaultPackageManager,
discoverAndLoadExtensions,
@@ -967,10 +974,32 @@ export async function createFnAgent(options: AgentOptions): Promise<AgentResult>
const modelRegistry = ModelRegistry.create(authStorage, getModelRegistryModelsPath());
await registerExtensionProviders(options.cwd, modelRegistry);
// Build the pi built-in tool set. We deliberately do NOT use the bundled
// `createCodingTools` / `createReadOnlyTools` presets — they're missing
// tools that pi-claude-cli's Claude→pi name mapping depends on (Glob→find,
// Grep→grep). When a coding session ran via Claude CLI tried `Glob`, pi
// returned "Tool find not found" and the agent looped. Compose explicitly
// so every tool referenced by tool-mapping.ts is registered.
const tools =
options.tools === "readonly"
? createReadOnlyTools(options.cwd)
: createCodingTools(options.cwd);
? [
createReadTool(options.cwd),
createGrepTool(options.cwd),
createFindTool(options.cwd),
createLsTool(options.cwd),
]
: [
createReadTool(options.cwd),
createBashTool(options.cwd),
createEditTool(options.cwd),
createWriteTool(options.cwd),
createGrepTool(options.cwd),
createFindTool(options.cwd),
createLsTool(options.cwd),
];
// Suppress lint about unused presets — kept in scope for incremental migration.
void createCodingTools;
void createReadOnlyTools;
// Detect if this is a worktree session and apply path boundaries
const worktreePath = options.cwd;