feat(FN-2703): support custom MCP tools in plan generation
- Remove ToolSearch prerequisite so custom MCP tools can be used during triage and plan generation flows - Align built-in tool sets between provider wiring and prompt builder handling, including custom ls behavior - Expand pi-claude-cli tests for event bridge, MCP config, prompt builder, and tool mapping regressions - Add FN-2703 changeset and delivery documentation for the published @runfusion/fusion package
This commit is contained in:
@@ -61,6 +61,12 @@ import { isPiKnownClaudeTool } from "./tool-mapping.js";
|
||||
* arrives (e.g. someone embeds pi-claude-cli without a stuck detector).
|
||||
*/
|
||||
const INACTIVITY_TIMEOUT_MS = 30 * 60_000;
|
||||
const DEBUG_STREAM = process.env.PI_CLAUDE_CLI_DEBUG === "1";
|
||||
|
||||
function debugLog(message: string): void {
|
||||
if (!DEBUG_STREAM) return;
|
||||
console.error(`[pi-claude-cli] ${message}`);
|
||||
}
|
||||
|
||||
/** Extended stream options: pi's SimpleStreamOptions plus optional cwd and mcpConfigPath */
|
||||
type StreamViaCLiOptions = SimpleStreamOptions & {
|
||||
@@ -267,10 +273,16 @@ export function streamViaCli(
|
||||
msg.event.content_block?.type === "tool_use"
|
||||
) {
|
||||
const toolName = msg.event.content_block.name;
|
||||
if (toolName && isPiKnownClaudeTool(toolName)) {
|
||||
// Built-in tool (Read/Write/etc.) OR custom MCP tool (mcp__custom-tools__*)
|
||||
// Internal Claude Code tools (ToolSearch, Task, etc.) are excluded
|
||||
sawBuiltInOrCustomTool = true;
|
||||
if (toolName) {
|
||||
const piKnownTool = isPiKnownClaudeTool(toolName);
|
||||
debugLog(
|
||||
`top-level tool_use seen: ${toolName} (piKnown=${piKnownTool ? "yes" : "no"})`,
|
||||
);
|
||||
if (piKnownTool) {
|
||||
// Built-in tool (Read/Write/etc.) OR custom MCP tool (mcp__custom-tools__*)
|
||||
// Internal Claude Code tools (ToolSearch, Task, etc.) are excluded
|
||||
sawBuiltInOrCustomTool = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,6 +293,7 @@ export function streamViaCli(
|
||||
msg.event.type === "message_stop" &&
|
||||
sawBuiltInOrCustomTool
|
||||
) {
|
||||
debugLog("break-early triggered at message_stop after pi-known tool_use");
|
||||
broken = true; // Set guard BEFORE rl.close() to prevent buffered lines
|
||||
clearTimeout(inactivityTimer);
|
||||
// Pi will execute these tools. Kill subprocess to prevent CLI from executing them.
|
||||
|
||||
Reference in New Issue
Block a user