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

export const GetSymbolDetailsInput = z.object({
  symbol: z.string().describe('Symbol name to resolve'),
  file_path: z.string().optional().describe('Optional file path to narrow search'),
});
export type GetSymbolDetailsInputT = z.infer<typeof GetSymbolDetailsInput>;

const DESCRIPTION =
  'Returns type signature, definition location, and usage count for a named symbol. ' +
  'Use after get_codebase_overview to dive deeper into specific functions, classes, or variables.';

const { toolDef: getSymbolDetails, execute: executeGetSymbolDetails } =
  makeCodecontextTool<GetSymbolDetailsInputT>({
    name: 'get_symbol_details',
    schema: GetSymbolDetailsInput,
    description: DESCRIPTION,
    jsonParameters: {
      type: 'object',
      properties: {
        symbol: { type: 'string', description: 'Symbol name to resolve' },
        file_path: { type: 'string', description: 'Optional file path to narrow search' },
      },
      required: ['symbol'],
      additionalProperties: false,
    },
    mapArgs: (input) => ({ symbol: input.symbol, file_path: input.file_path }),
  });

export { getSymbolDetails, executeGetSymbolDetails };
