import { z } from 'zod';
import { makeCodecontextTool } from './factory.js';

export const GetMiddlewareInput = z.object({});
export type GetMiddlewareInputT = z.infer<typeof GetMiddlewareInput>;

const DESCRIPTION =
  'Detects middleware registrations in the project. Identifies auth, CORS, rate-limit, ' +
  'security-headers, error-handler, logging, and validation middleware by analyzing ' +
  'import names (@fastify/cors, helmet, etc.) and registration patterns ' +
  '(app.register, app.addHook, app.setErrorHandler).';

const { toolDef: getMiddleware, execute: executeGetMiddleware } =
  makeCodecontextTool<GetMiddlewareInputT>({
    name: 'get_middleware',
    schema: GetMiddlewareInput,
    description: DESCRIPTION,
    jsonParameters: {
      type: 'object',
      properties: {},
      additionalProperties: false,
    },
    mapArgs: () => ({}),
  });

export { getMiddleware, executeGetMiddleware };
