/**
* Shared help handling for flux and scout tools
* Extracts 100% duplicated help logic from flux.ts and scout.ts
*/
import type { ZodType } from "zod";
import { generateHelp, formatHelpMarkdown, formatHelpJson } from "./help.js";
/**
* Help action input shape
*/
export interface HelpInput {
action: "help";
topic?: string;
format?: "markdown" | "json";
}
/**
* Handle help action for any schema
* Consolidates identical logic from flux.ts:29-37 and scout.ts:32-40
*
* @param input - Help input with optional topic and format
* @param schema - Zod schema to generate help from
* @returns Formatted help string (markdown or JSON)
*/
export function handleHelpAction(input: HelpInput, schema: ZodType): string {
const entries = generateHelp(schema, input.topic);
if (input.format === "json") {
return formatHelpJson(entries);
}
return formatHelpMarkdown(entries);
}