{"version":3,"file":"agent-format-parameter.mjs","names":[],"sources":["../../../../src/codemods/v1/not-implemented/agent-format-parameter.ts"],"sourcesContent":["/* eslint-disable no-warning-comments */\nimport { insertCommentOnce } from '../../lib/add-comment';\nimport { createTransformer } from '../../lib/create-transformer';\n\n/**\n * Adds a FIXME comment above the format parameter in agent.generate() and agent.stream() calls.\n * The format parameter has been removed in v1 and requires manual migration.\n *\n * Before:\n * agent.generate('prompt', { format: 'aisdk' })\n *\n * After:\n * agent.generate('prompt', {\n *   /* FIXME(mastra): The format parameter has been removed. See: https://mastra.ai/guides/migrations/upgrade-to-v1/agent#format-parameter-from-stream-and-generate *\\/\n *   format: 'aisdk'\n * })\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n  const { j, root } = context;\n\n  const COMMENT_MESSAGE =\n    'FIXME(mastra): The format parameter has been removed. See: https://mastra.ai/guides/migrations/upgrade-to-v1/agent#format-parameter-from-stream-and-generate';\n\n  // Track Agent instances\n  const agentInstances = new Set<string>();\n\n  root\n    .find(j.NewExpression, {\n      callee: {\n        type: 'Identifier',\n        name: 'Agent',\n      },\n    })\n    .forEach(path => {\n      const parent = path.parent.value;\n      if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') {\n        agentInstances.add(parent.id.name);\n      }\n    });\n\n  // Find agent.generate() and agent.stream() calls\n  root\n    .find(j.CallExpression)\n    .filter(path => {\n      const { callee } = path.value;\n      if (callee.type !== 'MemberExpression') return false;\n      if (callee.object.type !== 'Identifier') return false;\n      if (callee.property.type !== 'Identifier') return false;\n\n      // Only process if called on an Agent instance\n      if (!agentInstances.has(callee.object.name)) return false;\n\n      // Only process generate() and stream() methods\n      return callee.property.name === 'generate' || callee.property.name === 'stream';\n    })\n    .forEach(path => {\n      const args = path.value.arguments;\n\n      // We're looking for calls with an options object that has format parameter\n      if (args.length < 2) return;\n\n      const optionsArg = args[1];\n      if (!optionsArg || optionsArg.type !== 'ObjectExpression') return;\n      if (!optionsArg.properties) return;\n\n      // Find the format property\n      optionsArg.properties.forEach(prop => {\n        if (\n          (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n          prop.key?.type === 'Identifier' &&\n          prop.key.name === 'format'\n        ) {\n          // Add FIXME comment to the format property\n          const added = insertCommentOnce(prop, j, COMMENT_MESSAGE);\n          if (added) {\n            context.hasChanges = true;\n          }\n        }\n      });\n    });\n\n  if (context.hasChanges) {\n    context.messages.push(`Not Implemented ${fileInfo.path}: The format 'aisdk' parameter has been removed.`);\n  }\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAA,iCAAe,mBAAmB,UAAU,KAAK,SAAS,YAAY;CACpE,MAAM,EAAE,GAAG,SAAS;CAEpB,MAAM,kBACJ;CAGF,MAAM,iCAAiB,IAAI,IAAY;CAEvC,KACG,KAAK,EAAE,eAAe,EACrB,QAAQ;EACN,MAAM;EACN,MAAM;CACR,EACF,CAAC,CAAC,CACD,SAAQ,SAAQ;EACf,MAAM,SAAS,KAAK,OAAO;EAC3B,IAAI,OAAO,SAAS,wBAAwB,OAAO,GAAG,SAAS,cAC7D,eAAe,IAAI,OAAO,GAAG,IAAI;CAErC,CAAC;CAGH,KACG,KAAK,EAAE,cAAc,CAAC,CACtB,QAAO,SAAQ;EACd,MAAM,EAAE,WAAW,KAAK;EACxB,IAAI,OAAO,SAAS,oBAAoB,OAAO;EAC/C,IAAI,OAAO,OAAO,SAAS,cAAc,OAAO;EAChD,IAAI,OAAO,SAAS,SAAS,cAAc,OAAO;EAGlD,IAAI,CAAC,eAAe,IAAI,OAAO,OAAO,IAAI,GAAG,OAAO;EAGpD,OAAO,OAAO,SAAS,SAAS,cAAc,OAAO,SAAS,SAAS;CACzE,CAAC,CAAC,CACD,SAAQ,SAAQ;EACf,MAAM,OAAO,KAAK,MAAM;EAGxB,IAAI,KAAK,SAAS,GAAG;EAErB,MAAM,aAAa,KAAK;EACxB,IAAI,CAAC,cAAc,WAAW,SAAS,oBAAoB;EAC3D,IAAI,CAAC,WAAW,YAAY;EAG5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