{"version":3,"file":"agent-property-access.mjs","names":[],"sources":["../../../src/codemods/v1/agent-property-access.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances } from '../lib/utils';\n\n/**\n * Transforms Agent property access to method calls.\n * - agent.llm → agent.getLLM()\n * - agent.tools → agent.getTools()\n * - agent.instructions → agent.getInstructions()\n *\n * Only transforms properties on variables that were instantiated with `new Agent(...)`\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n  const { j, root } = context;\n\n  // Map of property names to their corresponding method names\n  const propertyToMethod: Record<string, string> = {\n    llm: 'getLLM',\n    tools: 'getTools',\n    instructions: 'getInstructions',\n  };\n\n  // Track variable names that are Agent instances\n  const agentVariables = trackClassInstances(j, root, 'Agent');\n\n  // Early return if no Agent instances found\n  if (agentVariables.size === 0) return;\n\n  // Find all member expressions where object is an Agent variable and property is one we want to transform\n  root.find(j.MemberExpression).forEach(path => {\n    const node = path.node;\n\n    // Check if the object is an identifier that's an Agent instance\n    if (node.object.type !== 'Identifier' || !agentVariables.has(node.object.name)) {\n      return;\n    }\n\n    // Check if the property is one we want to transform\n    if (node.property.type !== 'Identifier') {\n      return;\n    }\n\n    const propertyName = node.property.name;\n    const methodName = propertyToMethod[propertyName];\n\n    if (!methodName) {\n      return;\n    }\n\n    // Transform the member expression to a call expression\n    const callExpression = j.callExpression(j.memberExpression(node.object, j.identifier(methodName)), []);\n\n    // Replace the member expression with the call expression\n    j(path).replaceWith(callExpression);\n\n    context.hasChanges = true;\n  });\n\n  if (context.hasChanges) {\n    context.messages.push(`Transformed Agent property access to method calls`);\n  }\n});\n"],"mappings":";;;;;;;;;;;AAWA,IAAA,gCAAe,mBAAmB,WAAW,MAAM,UAAU,YAAY;CACvE,MAAM,EAAE,GAAG,SAAS;CAGpB,MAAM,mBAA2C;EAC/C,KAAK;EACL,OAAO;EACP,cAAc;CAChB;CAGA,MAAM,iBAAiB,oBAAoB,GAAG,MAAM,OAAO;CAG3D,IAAI,eAAe,SAAS,GAAG;CAG/B,KAAK,KAAK,EAAE,gBAAgB,CAAC,CAAC,SAAQ,SAAQ;EAC5C,MAAM,OAAO,KAAK;EAGlB,IAAI,KAAK,OAAO,SAAS,gBAAgB,CAAC,eAAe,IAAI,KAAK,OAAO,IAAI,GAC3E;EAIF,IAAI,KAAK,SAAS,SAAS,cACzB;EAGF,MAAM,eAAe,KAAK,SAAS;EACnC,MAAM,aAAa,iBAAiB;EAEpC,IAAI,CAAC,YACH;EAIF,MAAM,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,KAAK,QAAQ,EAAE,WAAW,UAAU,CAAC,GAAG,CAAC,CAAC;EAGrG,EAAE,IAAI,CAAC,CAAC,YAAY,cAAc;EAElC,QAAQ,aAAa;CACvB,CAAC;CAED,IAAI,QAAQ,YACV,QAAQ,SAAS,KAAK,mDAAmD;AAE7E,CAAC"}