@mastra/codemod 0.0.0-allow-to-pass-a-mastra-url-instance-20251105224938 → 0.0.0-cloud-storage-adapter-20251106204059

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +29 -11
  3. package/dist/codemods/v1/agent-generate-stream-v-next.js +83 -0
  4. package/dist/codemods/v1/agent-generate-stream-v-next.js.map +1 -0
  5. package/dist/codemods/v1/agent-get-agents.js +74 -0
  6. package/dist/codemods/v1/agent-get-agents.js.map +1 -0
  7. package/dist/codemods/v1/agent-processor-methods.js +85 -0
  8. package/dist/codemods/v1/agent-processor-methods.js.map +1 -0
  9. package/dist/codemods/v1/agent-property-access.js +81 -0
  10. package/dist/codemods/v1/agent-property-access.js.map +1 -0
  11. package/dist/codemods/v1/agent-voice.js +76 -0
  12. package/dist/codemods/v1/agent-voice.js.map +1 -0
  13. package/dist/codemods/v1/evals-get-scorers.js +74 -0
  14. package/dist/codemods/v1/evals-get-scorers.js.map +1 -0
  15. package/dist/codemods/v1/experimental-auth.js +63 -0
  16. package/dist/codemods/v1/experimental-auth.js.map +1 -0
  17. package/dist/codemods/v1/mastra-core-imports.js +1 -1
  18. package/dist/codemods/v1/mastra-core-imports.js.map +1 -1
  19. package/dist/codemods/v1/mcp-get-mcp-servers.js +74 -0
  20. package/dist/codemods/v1/mcp-get-mcp-servers.js.map +1 -0
  21. package/dist/codemods/v1/mcp-get-tools.js +74 -0
  22. package/dist/codemods/v1/mcp-get-tools.js.map +1 -0
  23. package/dist/codemods/v1/mcp-get-toolsets.js +74 -0
  24. package/dist/codemods/v1/mcp-get-toolsets.js.map +1 -0
  25. package/dist/codemods/v1/voice-property-names.js +78 -0
  26. package/dist/codemods/v1/voice-property-names.js.map +1 -0
  27. package/dist/codemods/v1/workflows-get-workflows.js +74 -0
  28. package/dist/codemods/v1/workflows-get-workflows.js.map +1 -0
  29. package/dist/index.js +69 -2
  30. package/dist/index.js.map +1 -1
  31. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/evals-get-scorers.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms Mastra getScorers method to listScorers:\n * - mastra.getScorers() → mastra.listScorers()\n *\n * Only transforms methods on variables that were instantiated with `new Mastra(...)`\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Track variable names that are Mastra instances\n const mastraVariables = new Set<string>();\n\n // Find all variable declarations with new Mastra() assignments\n root.find(j.VariableDeclarator).forEach(path => {\n const node = path.node;\n\n // Check if the init is a new Mastra() expression\n if (\n node.init &&\n node.init.type === 'NewExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'Mastra' &&\n node.id.type === 'Identifier'\n ) {\n mastraVariables.add(node.id.name);\n }\n });\n\n // Early return if no Mastra instances found\n if (mastraVariables.size === 0) return;\n\n // Find all call expressions where the callee is mastra.getScorers\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., mastra.getScorers)\n if (node.callee.type !== 'MemberExpression') {\n return;\n }\n\n const callee = node.callee;\n\n // Check if the object is a Mastra variable\n if (callee.object.type !== 'Identifier' || !mastraVariables.has(callee.object.name)) {\n return;\n }\n\n // Check if the property is 'getScorers'\n if (callee.property.type !== 'Identifier' || callee.property.name !== 'getScorers') {\n return;\n }\n\n // Rename the method to 'listScorers'\n callee.property.name = 'listScorers';\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed Mastra method: getScorers → listScorers`);\n }\n});\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;AACtE,UAAM,IAAI,IAAI;AACd,UAAM,OAAO,EAAE,SAAS,MAAM;AAC9B,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,UAAU,CAAC;AAAA,IACb;AAGA,gBAAY,UAAU,KAAK,SAAS,OAAO;AAG3C,YAAQ,SAAS,QAAQ,aAAW,IAAI,OAAO,OAAO,CAAC;AAGvD,WAAO,QAAQ,aAAa,KAAK,SAAS,EAAE,OAAO,SAAS,CAAC,IAAI;AAAA,EACnE;AACF;;;AD5CA,IAAO,4BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,kBAAkB,oBAAI,IAAY;AAGxC,OAAK,KAAK,EAAE,kBAAkB,EAAE,QAAQ,UAAQ;AAC9C,UAAM,OAAO,KAAK;AAGlB,QACE,KAAK,QACL,KAAK,KAAK,SAAS,mBACnB,KAAK,KAAK,OAAO,SAAS,gBAC1B,KAAK,KAAK,OAAO,SAAS,YAC1B,KAAK,GAAG,SAAS,cACjB;AACA,sBAAgB,IAAI,KAAK,GAAG,IAAI;AAAA,IAClC;AAAA,EACF,CAAC;AAGD,MAAI,gBAAgB,SAAS,EAAG;AAGhC,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,UAAM,OAAO,KAAK;AAGlB,QAAI,KAAK,OAAO,SAAS,oBAAoB;AAC3C;AAAA,IACF;AAEA,UAAM,SAAS,KAAK;AAGpB,QAAI,OAAO,OAAO,SAAS,gBAAgB,CAAC,gBAAgB,IAAI,OAAO,OAAO,IAAI,GAAG;AACnF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,SAAS,gBAAgB,OAAO,SAAS,SAAS,cAAc;AAClF;AAAA,IACF;AAGA,WAAO,SAAS,OAAO;AACvB,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,0DAAqD;AAAA,EAC7E;AACF,CAAC;","names":[]}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/codemods/v1/experimental-auth.ts
21
+ var experimental_auth_exports = {};
22
+ __export(experimental_auth_exports, {
23
+ default: () => experimental_auth_default
24
+ });
25
+ module.exports = __toCommonJS(experimental_auth_exports);
26
+
27
+ // src/codemods/lib/create-transformer.ts
28
+ function createTransformer(transformFn) {
29
+ return function transformer(fileInfo, api, options) {
30
+ const j = api.jscodeshift;
31
+ const root = j(fileInfo.source);
32
+ const context = {
33
+ j,
34
+ root,
35
+ hasChanges: false,
36
+ messages: []
37
+ };
38
+ transformFn(fileInfo, api, options, context);
39
+ context.messages.forEach((message) => api.report(message));
40
+ return context.hasChanges ? root.toSource({ quote: "single" }) : null;
41
+ };
42
+ }
43
+
44
+ // src/codemods/v1/experimental-auth.ts
45
+ var experimental_auth_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ root.find(j.NewExpression, {
48
+ callee: { type: "Identifier", name: "Mastra" }
49
+ }).forEach((mastraPath) => {
50
+ const configArg = mastraPath.node.arguments[0];
51
+ if (!configArg || configArg.type !== "ObjectExpression") return;
52
+ configArg.properties?.forEach((prop) => {
53
+ if ((prop.type === "Property" || prop.type === "ObjectProperty") && prop.key.type === "Identifier" && prop.key.name === "experimental_auth") {
54
+ prop.key.name = "auth";
55
+ context.hasChanges = true;
56
+ }
57
+ });
58
+ });
59
+ if (context.hasChanges) {
60
+ context.messages.push(`Renamed experimental_auth to auth in Mastra configuration`);
61
+ }
62
+ });
63
+ //# sourceMappingURL=experimental-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/experimental-auth.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Renames experimental_auth to auth in Mastra configuration.\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Find all new Mastra({ ... }) expressions\n root\n .find(j.NewExpression, {\n callee: { type: 'Identifier', name: 'Mastra' },\n })\n .forEach(mastraPath => {\n const configArg = mastraPath.node.arguments[0];\n if (!configArg || configArg.type !== 'ObjectExpression') return;\n\n // Find experimental_auth property in the Mastra config object\n configArg.properties?.forEach((prop: any) => {\n if (\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'experimental_auth'\n ) {\n // Rename to 'auth'\n prop.key.name = 'auth';\n context.hasChanges = true;\n }\n });\n });\n\n if (context.hasChanges) {\n context.messages.push(`Renamed experimental_auth to auth in Mastra configuration`);\n }\n});\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;AACtE,UAAM,IAAI,IAAI;AACd,UAAM,OAAO,EAAE,SAAS,MAAM;AAC9B,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,UAAU,CAAC;AAAA,IACb;AAGA,gBAAY,UAAU,KAAK,SAAS,OAAO;AAG3C,YAAQ,SAAS,QAAQ,aAAW,IAAI,OAAO,OAAO,CAAC;AAGvD,WAAO,QAAQ,aAAa,KAAK,SAAS,EAAE,OAAO,SAAS,CAAC,IAAI;AAAA,EACnE;AACF;;;AD/CA,IAAO,4BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,OACG,KAAK,EAAE,eAAe;AAAA,IACrB,QAAQ,EAAE,MAAM,cAAc,MAAM,SAAS;AAAA,EAC/C,CAAC,EACA,QAAQ,gBAAc;AACrB,UAAM,YAAY,WAAW,KAAK,UAAU,CAAC;AAC7C,QAAI,CAAC,aAAa,UAAU,SAAS,mBAAoB;AAGzD,cAAU,YAAY,QAAQ,CAAC,SAAc;AAC3C,WACG,KAAK,SAAS,cAAc,KAAK,SAAS,qBAC3C,KAAK,IAAI,SAAS,gBAClB,KAAK,IAAI,SAAS,qBAClB;AAEA,aAAK,IAAI,OAAO;AAChB,gBAAQ,aAAa;AAAA,MACvB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAEH,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,2DAA2D;AAAA,EACnF;AACF,CAAC;","names":[]}
@@ -68,7 +68,7 @@ var EXPORT_TO_SUBPATH = {
68
68
  // Voice
69
69
  CompositeVoice: "@mastra/core/voice",
70
70
  // Scorers/Evals
71
- runExperiment: "@mastra/core/scores",
71
+ runEvals: "@mastra/core/scores",
72
72
  createScorer: "@mastra/core/scores",
73
73
  // Server
74
74
  registerApiRoute: "@mastra/core/server",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/codemods/v1/mastra-core-imports.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * For v1 we removed all top-level exports from \"@mastra/core\" except for `Mastra` and `type Config`.\n * All other imports should use subpath imports, e.g. `import { Agent } from \"@mastra/core/agent\"`.\n *\n * This codemod updates all imports from \"@mastra/core\" to use the new subpath imports. It leaves imports to `Mastra` and `Config` unchanged.\n */\n\n// TODO: Do not hardcode this mapping, generate it from the package's exports in the future\nconst EXPORT_TO_SUBPATH: Record<string, string> = {\n // Agent\n Agent: '@mastra/core/agent',\n\n // Tools\n createTool: '@mastra/core/tools',\n Tool: '@mastra/core/tools',\n\n // Workflows\n createWorkflow: '@mastra/core/workflows',\n createStep: '@mastra/core/workflows',\n Workflow: '@mastra/core/workflows',\n Step: '@mastra/core/workflows',\n\n // Request Context\n RequestContext: '@mastra/core/request-context',\n\n // Processors\n BatchPartsProcessor: '@mastra/core/processors',\n PIIDetector: '@mastra/core/processors',\n ModerationProcessor: '@mastra/core/processors',\n TokenLimiterProcessor: '@mastra/core/processors',\n Processor: '@mastra/core/processors',\n UnicodeNormalizer: '@mastra/core/processors',\n SystemPromptScrubber: '@mastra/core/processors',\n PromptInjectionDetector: '@mastra/core/processors',\n LanguageDetector: '@mastra/core/processors',\n\n // Voice\n CompositeVoice: '@mastra/core/voice',\n\n // Scorers/Evals\n runExperiment: '@mastra/core/scores',\n createScorer: '@mastra/core/scores',\n\n // Server\n registerApiRoute: '@mastra/core/server',\n\n // Tracing\n DefaultExporter: '@mastra/observability',\n CloudExporter: '@mastra/observability',\n\n // Streaming\n ChunkType: '@mastra/core/stream',\n MastraMessageV2: '@mastra/core/stream',\n\n // LLM/Models\n ModelRouterEmbeddingModel: '@mastra/core/llm',\n};\n\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Find all import declarations from '@mastra/core'\n root\n .find(j.ImportDeclaration, {\n source: { value: '@mastra/core' },\n })\n .forEach(importPath => {\n const node = importPath.node;\n const specifiers = node.specifiers || [];\n const declarationImportKind = node.importKind || 'value';\n\n // Categorize specifiers into those that stay vs those that move\n const { remainingSpecifiers, importsToMove } = categorizeImports(specifiers, declarationImportKind);\n\n // Early return: No imports to move\n if (importsToMove.length === 0) return;\n\n context.hasChanges = true;\n\n // Group imports by their target subpath\n const groupedImports = groupImportsBySubpath(importsToMove);\n\n // Create new import declarations for each subpath\n const newImports = createNewImports(j, groupedImports, context);\n\n // Insert new imports after the current one (in reverse to maintain order)\n insertImports(j, importPath, newImports);\n\n // Update or remove the original import\n updateOriginalImport(j, importPath, node, remainingSpecifiers, context);\n });\n});\n\n/**\n * Categorize import specifiers into those that stay vs those that move\n */\nfunction categorizeImports(specifiers: any[], declarationImportKind: 'type' | 'typeof' | 'value') {\n const remainingSpecifiers: any[] = [];\n const importsToMove: Array<{\n subpath: string;\n localName: string;\n importedName: string;\n importKind: 'type' | 'typeof' | 'value';\n isDeclarationType: boolean;\n }> = [];\n\n specifiers.forEach(specifier => {\n // Keep default and namespace imports as-is\n if (specifier.type !== 'ImportSpecifier') {\n remainingSpecifiers.push(specifier);\n return;\n }\n\n const imported = specifier.imported;\n const importedName = getImportedName(imported);\n const localName = specifier.local?.name || importedName;\n const specifierImportKind = specifier.importKind || 'value';\n\n // Determine effective importKind:\n // - If declaration is \"import type {}\", use 'type' for all specifiers\n // - Otherwise, use the specifier's own importKind\n const effectiveImportKind = declarationImportKind !== 'value' ? declarationImportKind : specifierImportKind;\n const isDeclarationType = declarationImportKind !== 'value';\n\n // Check if this import should be moved to a subpath\n const newSubpath = EXPORT_TO_SUBPATH[importedName];\n\n if (newSubpath) {\n importsToMove.push({\n subpath: newSubpath,\n localName,\n importedName,\n importKind: effectiveImportKind,\n isDeclarationType,\n });\n } else {\n // This import stays at '@mastra/core' (e.g., Mastra, Config)\n remainingSpecifiers.push(specifier);\n }\n });\n\n return { remainingSpecifiers, importsToMove };\n}\n\n/**\n * Extract the imported name from an import specifier\n */\nfunction getImportedName(imported: any): string {\n if (imported.type === 'Identifier') {\n return imported.name;\n }\n // Handle string literal imports (edge case)\n return imported.value || '';\n}\n\n/**\n * Group imports by their target subpath and importKind\n */\nfunction groupImportsBySubpath(\n importsToMove: Array<{\n subpath: string;\n localName: string;\n importedName: string;\n importKind: 'type' | 'typeof' | 'value';\n isDeclarationType: boolean;\n }>,\n) {\n const groupedImports = new Map<\n string,\n Array<{\n localName: string;\n importedName: string;\n importKind: 'type' | 'typeof' | 'value';\n isDeclarationType: boolean;\n }>\n >();\n\n importsToMove.forEach(({ subpath, localName, importedName, importKind, isDeclarationType }) => {\n // Create a key that includes both subpath and importKind to ensure separate import declarations\n const key = `${subpath}::${importKind}::${isDeclarationType}`;\n if (!groupedImports.has(key)) {\n groupedImports.set(key, []);\n }\n groupedImports.get(key)!.push({ localName, importedName, importKind, isDeclarationType });\n });\n\n return groupedImports;\n}\n\n/**\n * Create new import declarations for each subpath and importKind\n */\nfunction createNewImports(\n j: any,\n groupedImports: Map<\n string,\n Array<{\n localName: string;\n importedName: string;\n importKind: 'type' | 'typeof' | 'value';\n isDeclarationType: boolean;\n }>\n >,\n context: any,\n) {\n const newImports: any[] = [];\n\n groupedImports.forEach((imports, key) => {\n // Extract subpath, importKind, and isDeclarationType from the composite key\n const [subpath, importKind] = key.split('::');\n\n const newSpecifiers = imports.map(({ localName, importedName }) => {\n if (localName === importedName) {\n // import { Agent } from '@mastra/core/agent'\n return j.importSpecifier(j.identifier(importedName));\n } else {\n // import { Agent as MastraAgent } from '@mastra/core/agent'\n return j.importSpecifier(j.identifier(importedName), j.identifier(localName));\n }\n // Note: We don't set importKind on specifiers since we're creating\n // separate import declarations for each importKind. All specifiers in a type\n // import group will be in an \"import type\" declaration.\n });\n\n const newImport = j.importDeclaration(newSpecifiers, j.stringLiteral(subpath));\n\n // Set importKind on declaration if this is a type import (either declaration-level or inline)\n if (importKind !== 'value') {\n newImport.importKind = importKind;\n }\n\n newImports.push(newImport);\n\n // Log which imports were moved to which subpath\n const importList = imports.map(i => i.importedName).join(', ');\n const kindLabel = importKind !== 'value' ? ` (${importKind})` : '';\n context.messages.push(`Moved imports to '${subpath}'${kindLabel}: ${importList}`);\n });\n\n return newImports;\n}\n\n/**\n * Insert new imports after the current import (in reverse to maintain order)\n */\nfunction insertImports(j: any, importPath: any, newImports: any[]) {\n newImports.reverse().forEach(newImport => {\n j(importPath).insertAfter(newImport);\n });\n}\n\n/**\n * Update or remove the original import declaration\n */\nfunction updateOriginalImport(j: any, importPath: any, node: any, remainingSpecifiers: any[], context: any) {\n if (remainingSpecifiers.length > 0) {\n // Keep the original import with only the remaining specifiers\n node.specifiers = remainingSpecifiers;\n\n const remainingList = extractRemainingImportNames(remainingSpecifiers);\n if (remainingList) {\n context.messages.push(`Kept at '@mastra/core': ${remainingList}`);\n }\n } else {\n // Remove the original import entirely (all imports moved)\n j(importPath).remove();\n context.messages.push(`Removed original '@mastra/core' import (all imports moved to subpaths)`);\n }\n}\n\n/**\n * Extract the names of remaining imports for logging\n */\nfunction extractRemainingImportNames(remainingSpecifiers: any[]): string {\n return remainingSpecifiers\n .filter(s => s.type === 'ImportSpecifier')\n .map(s => s.imported?.name || s.local?.name)\n .filter(Boolean)\n .join(', ');\n}\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;AACtE,UAAM,IAAI,IAAI;AACd,UAAM,OAAO,EAAE,SAAS,MAAM;AAC9B,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,UAAU,CAAC;AAAA,IACb;AAGA,gBAAY,UAAU,KAAK,SAAS,OAAO;AAG3C,YAAQ,SAAS,QAAQ,aAAW,IAAI,OAAO,OAAO,CAAC;AAGvD,WAAO,QAAQ,aAAa,KAAK,SAAS,EAAE,OAAO,SAAS,CAAC,IAAI;AAAA,EACnE;AACF;;;AD1CA,IAAM,oBAA4C;AAAA;AAAA,EAEhD,OAAO;AAAA;AAAA,EAGP,YAAY;AAAA,EACZ,MAAM;AAAA;AAAA,EAGN,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,MAAM;AAAA;AAAA,EAGN,gBAAgB;AAAA;AAAA,EAGhB,qBAAqB;AAAA,EACrB,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,kBAAkB;AAAA;AAAA,EAGlB,gBAAgB;AAAA;AAAA,EAGhB,eAAe;AAAA,EACf,cAAc;AAAA;AAAA,EAGd,kBAAkB;AAAA;AAAA,EAGlB,iBAAiB;AAAA,EAC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EAAE,YAAY,EAAE,KAAK,IAAI;AAC7D,UAAM,YAAY,eAAe,UAAU,KAAK,UAAU,MAAM;AAChE,YAAQ,SAAS,KAAK,qBAAqB,OAAO,IAAI,SAAS,KAAK,UAAU,EAAE;AAAA,EAClF,CAAC;AAED,SAAO;AACT;AAKA,SAAS,cAAc,GAAQ,YAAiB,YAAmB;AACjE,aAAW,QAAQ,EAAE,QAAQ,eAAa;AACxC,MAAE,UAAU,EAAE,YAAY,SAAS;AAAA,EACrC,CAAC;AACH;AAKA,SAAS,qBAAqB,GAAQ,YAAiB,MAAW,qBAA4B,SAAc;AAC1G,MAAI,oBAAoB,SAAS,GAAG;AAElC,SAAK,aAAa;AAElB,UAAM,gBAAgB,4BAA4B,mBAAmB;AACrE,QAAI,eAAe;AACjB,cAAQ,SAAS,KAAK,2BAA2B,aAAa,EAAE;AAAA,IAClE;AAAA,EACF,OAAO;AAEL,MAAE,UAAU,EAAE,OAAO;AACrB,YAAQ,SAAS,KAAK,wEAAwE;AAAA,EAChG;AACF;AAKA,SAAS,4BAA4B,qBAAoC;AACvE,SAAO,oBACJ,OAAO,OAAK,EAAE,SAAS,iBAAiB,EACxC,IAAI,OAAK,EAAE,UAAU,QAAQ,EAAE,OAAO,IAAI,EAC1C,OAAO,OAAO,EACd,KAAK,IAAI;AACd;","names":[]}
1
+ {"version":3,"sources":["../../../src/codemods/v1/mastra-core-imports.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * For v1 we removed all top-level exports from \"@mastra/core\" except for `Mastra` and `type Config`.\n * All other imports should use subpath imports, e.g. `import { Agent } from \"@mastra/core/agent\"`.\n *\n * This codemod updates all imports from \"@mastra/core\" to use the new subpath imports. It leaves imports to `Mastra` and `Config` unchanged.\n */\n\n// TODO: Do not hardcode this mapping, generate it from the package's exports in the future\nconst EXPORT_TO_SUBPATH: Record<string, string> = {\n // Agent\n Agent: '@mastra/core/agent',\n\n // Tools\n createTool: '@mastra/core/tools',\n Tool: '@mastra/core/tools',\n\n // Workflows\n createWorkflow: '@mastra/core/workflows',\n createStep: '@mastra/core/workflows',\n Workflow: '@mastra/core/workflows',\n Step: '@mastra/core/workflows',\n\n // Request Context\n RequestContext: '@mastra/core/request-context',\n\n // Processors\n BatchPartsProcessor: '@mastra/core/processors',\n PIIDetector: '@mastra/core/processors',\n ModerationProcessor: '@mastra/core/processors',\n TokenLimiterProcessor: '@mastra/core/processors',\n Processor: '@mastra/core/processors',\n UnicodeNormalizer: '@mastra/core/processors',\n SystemPromptScrubber: '@mastra/core/processors',\n PromptInjectionDetector: '@mastra/core/processors',\n LanguageDetector: '@mastra/core/processors',\n\n // Voice\n CompositeVoice: '@mastra/core/voice',\n\n // Scorers/Evals\n runEvals: '@mastra/core/scores',\n createScorer: '@mastra/core/scores',\n\n // Server\n registerApiRoute: '@mastra/core/server',\n\n // Tracing\n DefaultExporter: '@mastra/observability',\n CloudExporter: '@mastra/observability',\n\n // Streaming\n ChunkType: '@mastra/core/stream',\n MastraMessageV2: '@mastra/core/stream',\n\n // LLM/Models\n ModelRouterEmbeddingModel: '@mastra/core/llm',\n};\n\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Find all import declarations from '@mastra/core'\n root\n .find(j.ImportDeclaration, {\n source: { value: '@mastra/core' },\n })\n .forEach(importPath => {\n const node = importPath.node;\n const specifiers = node.specifiers || [];\n const declarationImportKind = node.importKind || 'value';\n\n // Categorize specifiers into those that stay vs those that move\n const { remainingSpecifiers, importsToMove } = categorizeImports(specifiers, declarationImportKind);\n\n // Early return: No imports to move\n if (importsToMove.length === 0) return;\n\n context.hasChanges = true;\n\n // Group imports by their target subpath\n const groupedImports = groupImportsBySubpath(importsToMove);\n\n // Create new import declarations for each subpath\n const newImports = createNewImports(j, groupedImports, context);\n\n // Insert new imports after the current one (in reverse to maintain order)\n insertImports(j, importPath, newImports);\n\n // Update or remove the original import\n updateOriginalImport(j, importPath, node, remainingSpecifiers, context);\n });\n});\n\n/**\n * Categorize import specifiers into those that stay vs those that move\n */\nfunction categorizeImports(specifiers: any[], declarationImportKind: 'type' | 'typeof' | 'value') {\n const remainingSpecifiers: any[] = [];\n const importsToMove: Array<{\n subpath: string;\n localName: string;\n importedName: string;\n importKind: 'type' | 'typeof' | 'value';\n isDeclarationType: boolean;\n }> = [];\n\n specifiers.forEach(specifier => {\n // Keep default and namespace imports as-is\n if (specifier.type !== 'ImportSpecifier') {\n remainingSpecifiers.push(specifier);\n return;\n }\n\n const imported = specifier.imported;\n const importedName = getImportedName(imported);\n const localName = specifier.local?.name || importedName;\n const specifierImportKind = specifier.importKind || 'value';\n\n // Determine effective importKind:\n // - If declaration is \"import type {}\", use 'type' for all specifiers\n // - Otherwise, use the specifier's own importKind\n const effectiveImportKind = declarationImportKind !== 'value' ? declarationImportKind : specifierImportKind;\n const isDeclarationType = declarationImportKind !== 'value';\n\n // Check if this import should be moved to a subpath\n const newSubpath = EXPORT_TO_SUBPATH[importedName];\n\n if (newSubpath) {\n importsToMove.push({\n subpath: newSubpath,\n localName,\n importedName,\n importKind: effectiveImportKind,\n isDeclarationType,\n });\n } else {\n // This import stays at '@mastra/core' (e.g., Mastra, Config)\n remainingSpecifiers.push(specifier);\n }\n });\n\n return { remainingSpecifiers, importsToMove };\n}\n\n/**\n * Extract the imported name from an import specifier\n */\nfunction getImportedName(imported: any): string {\n if (imported.type === 'Identifier') {\n return imported.name;\n }\n // Handle string literal imports (edge case)\n return imported.value || '';\n}\n\n/**\n * Group imports by their target subpath and importKind\n */\nfunction groupImportsBySubpath(\n importsToMove: Array<{\n subpath: string;\n localName: string;\n importedName: string;\n importKind: 'type' | 'typeof' | 'value';\n isDeclarationType: boolean;\n }>,\n) {\n const groupedImports = new Map<\n string,\n Array<{\n localName: string;\n importedName: string;\n importKind: 'type' | 'typeof' | 'value';\n isDeclarationType: boolean;\n }>\n >();\n\n importsToMove.forEach(({ subpath, localName, importedName, importKind, isDeclarationType }) => {\n // Create a key that includes both subpath and importKind to ensure separate import declarations\n const key = `${subpath}::${importKind}::${isDeclarationType}`;\n if (!groupedImports.has(key)) {\n groupedImports.set(key, []);\n }\n groupedImports.get(key)!.push({ localName, importedName, importKind, isDeclarationType });\n });\n\n return groupedImports;\n}\n\n/**\n * Create new import declarations for each subpath and importKind\n */\nfunction createNewImports(\n j: any,\n groupedImports: Map<\n string,\n Array<{\n localName: string;\n importedName: string;\n importKind: 'type' | 'typeof' | 'value';\n isDeclarationType: boolean;\n }>\n >,\n context: any,\n) {\n const newImports: any[] = [];\n\n groupedImports.forEach((imports, key) => {\n // Extract subpath, importKind, and isDeclarationType from the composite key\n const [subpath, importKind] = key.split('::');\n\n const newSpecifiers = imports.map(({ localName, importedName }) => {\n if (localName === importedName) {\n // import { Agent } from '@mastra/core/agent'\n return j.importSpecifier(j.identifier(importedName));\n } else {\n // import { Agent as MastraAgent } from '@mastra/core/agent'\n return j.importSpecifier(j.identifier(importedName), j.identifier(localName));\n }\n // Note: We don't set importKind on specifiers since we're creating\n // separate import declarations for each importKind. All specifiers in a type\n // import group will be in an \"import type\" declaration.\n });\n\n const newImport = j.importDeclaration(newSpecifiers, j.stringLiteral(subpath));\n\n // Set importKind on declaration if this is a type import (either declaration-level or inline)\n if (importKind !== 'value') {\n newImport.importKind = importKind;\n }\n\n newImports.push(newImport);\n\n // Log which imports were moved to which subpath\n const importList = imports.map(i => i.importedName).join(', ');\n const kindLabel = importKind !== 'value' ? ` (${importKind})` : '';\n context.messages.push(`Moved imports to '${subpath}'${kindLabel}: ${importList}`);\n });\n\n return newImports;\n}\n\n/**\n * Insert new imports after the current import (in reverse to maintain order)\n */\nfunction insertImports(j: any, importPath: any, newImports: any[]) {\n newImports.reverse().forEach(newImport => {\n j(importPath).insertAfter(newImport);\n });\n}\n\n/**\n * Update or remove the original import declaration\n */\nfunction updateOriginalImport(j: any, importPath: any, node: any, remainingSpecifiers: any[], context: any) {\n if (remainingSpecifiers.length > 0) {\n // Keep the original import with only the remaining specifiers\n node.specifiers = remainingSpecifiers;\n\n const remainingList = extractRemainingImportNames(remainingSpecifiers);\n if (remainingList) {\n context.messages.push(`Kept at '@mastra/core': ${remainingList}`);\n }\n } else {\n // Remove the original import entirely (all imports moved)\n j(importPath).remove();\n context.messages.push(`Removed original '@mastra/core' import (all imports moved to subpaths)`);\n }\n}\n\n/**\n * Extract the names of remaining imports for logging\n */\nfunction extractRemainingImportNames(remainingSpecifiers: any[]): string {\n return remainingSpecifiers\n .filter(s => s.type === 'ImportSpecifier')\n .map(s => s.imported?.name || s.local?.name)\n .filter(Boolean)\n .join(', ');\n}\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAA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BAA4B,SAAc;AAC1G,MAAI,oBAAoB,SAAS,GAAG;AAElC,SAAK,aAAa;AAElB,UAAM,gBAAgB,4BAA4B,mBAAmB;AACrE,QAAI,eAAe;AACjB,cAAQ,SAAS,KAAK,2BAA2B,aAAa,EAAE;AAAA,IAClE;AAAA,EACF,OAAO;AAEL,MAAE,UAAU,EAAE,OAAO;AACrB,YAAQ,SAAS,KAAK,wEAAwE;AAAA,EAChG;AACF;AAKA,SAAS,4BAA4B,qBAAoC;AACvE,SAAO,oBACJ,OAAO,OAAK,EAAE,SAAS,iBAAiB,EACxC,IAAI,OAAK,EAAE,UAAU,QAAQ,EAAE,OAAO,IAAI,EAC1C,OAAO,OAAO,EACd,KAAK,IAAI;AACd;","names":[]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/codemods/v1/mcp-get-mcp-servers.ts
21
+ var mcp_get_mcp_servers_exports = {};
22
+ __export(mcp_get_mcp_servers_exports, {
23
+ default: () => mcp_get_mcp_servers_default
24
+ });
25
+ module.exports = __toCommonJS(mcp_get_mcp_servers_exports);
26
+
27
+ // src/codemods/lib/create-transformer.ts
28
+ function createTransformer(transformFn) {
29
+ return function transformer(fileInfo, api, options) {
30
+ const j = api.jscodeshift;
31
+ const root = j(fileInfo.source);
32
+ const context = {
33
+ j,
34
+ root,
35
+ hasChanges: false,
36
+ messages: []
37
+ };
38
+ transformFn(fileInfo, api, options, context);
39
+ context.messages.forEach((message) => api.report(message));
40
+ return context.hasChanges ? root.toSource({ quote: "single" }) : null;
41
+ };
42
+ }
43
+
44
+ // src/codemods/v1/mcp-get-mcp-servers.ts
45
+ var mcp_get_mcp_servers_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ const mastraVariables = /* @__PURE__ */ new Set();
48
+ root.find(j.VariableDeclarator).forEach((path) => {
49
+ const node = path.node;
50
+ if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Mastra" && node.id.type === "Identifier") {
51
+ mastraVariables.add(node.id.name);
52
+ }
53
+ });
54
+ if (mastraVariables.size === 0) return;
55
+ root.find(j.CallExpression).forEach((path) => {
56
+ const node = path.node;
57
+ if (node.callee.type !== "MemberExpression") {
58
+ return;
59
+ }
60
+ const callee = node.callee;
61
+ if (callee.object.type !== "Identifier" || !mastraVariables.has(callee.object.name)) {
62
+ return;
63
+ }
64
+ if (callee.property.type !== "Identifier" || callee.property.name !== "getMCPServers") {
65
+ return;
66
+ }
67
+ callee.property.name = "listMCPServers";
68
+ context.hasChanges = true;
69
+ });
70
+ if (context.hasChanges) {
71
+ context.messages.push(`Transformed Mastra method: getMCPServers \u2192 listMCPServers`);
72
+ }
73
+ });
74
+ //# sourceMappingURL=mcp-get-mcp-servers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/mcp-get-mcp-servers.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms Mastra getMCPServers method to listMCPServers:\n * - mastra.getMCPServers() → mastra.listMCPServers()\n *\n * Only transforms methods on variables that were instantiated with `new Mastra(...)`\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Track variable names that are Mastra instances\n const mastraVariables = new Set<string>();\n\n // Find all variable declarations with new Mastra() assignments\n root.find(j.VariableDeclarator).forEach(path => {\n const node = path.node;\n\n // Check if the init is a new Mastra() expression\n if (\n node.init &&\n node.init.type === 'NewExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'Mastra' &&\n node.id.type === 'Identifier'\n ) {\n mastraVariables.add(node.id.name);\n }\n });\n\n // Early return if no Mastra instances found\n if (mastraVariables.size === 0) return;\n\n // Find all call expressions where the callee is mastra.getMCPServers\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., mastra.getMCPServers)\n if (node.callee.type !== 'MemberExpression') {\n return;\n }\n\n const callee = node.callee;\n\n // Check if the object is a Mastra variable\n if (callee.object.type !== 'Identifier' || !mastraVariables.has(callee.object.name)) {\n return;\n }\n\n // Check if the property is 'getMCPServers'\n if (callee.property.type !== 'Identifier' || callee.property.name !== 'getMCPServers') {\n return;\n }\n\n // Rename the method to 'listMCPServers'\n callee.property.name = 'listMCPServers';\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed Mastra method: getMCPServers → listMCPServers`);\n }\n});\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;AACtE,UAAM,IAAI,IAAI;AACd,UAAM,OAAO,EAAE,SAAS,MAAM;AAC9B,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,UAAU,CAAC;AAAA,IACb;AAGA,gBAAY,UAAU,KAAK,SAAS,OAAO;AAG3C,YAAQ,SAAS,QAAQ,aAAW,IAAI,OAAO,OAAO,CAAC;AAGvD,WAAO,QAAQ,aAAa,KAAK,SAAS,EAAE,OAAO,SAAS,CAAC,IAAI;AAAA,EACnE;AACF;;;AD5CA,IAAO,8BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,kBAAkB,oBAAI,IAAY;AAGxC,OAAK,KAAK,EAAE,kBAAkB,EAAE,QAAQ,UAAQ;AAC9C,UAAM,OAAO,KAAK;AAGlB,QACE,KAAK,QACL,KAAK,KAAK,SAAS,mBACnB,KAAK,KAAK,OAAO,SAAS,gBAC1B,KAAK,KAAK,OAAO,SAAS,YAC1B,KAAK,GAAG,SAAS,cACjB;AACA,sBAAgB,IAAI,KAAK,GAAG,IAAI;AAAA,IAClC;AAAA,EACF,CAAC;AAGD,MAAI,gBAAgB,SAAS,EAAG;AAGhC,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,UAAM,OAAO,KAAK;AAGlB,QAAI,KAAK,OAAO,SAAS,oBAAoB;AAC3C;AAAA,IACF;AAEA,UAAM,SAAS,KAAK;AAGpB,QAAI,OAAO,OAAO,SAAS,gBAAgB,CAAC,gBAAgB,IAAI,OAAO,OAAO,IAAI,GAAG;AACnF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,SAAS,gBAAgB,OAAO,SAAS,SAAS,iBAAiB;AACrF;AAAA,IACF;AAGA,WAAO,SAAS,OAAO;AACvB,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,gEAA2D;AAAA,EACnF;AACF,CAAC;","names":[]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/codemods/v1/mcp-get-tools.ts
21
+ var mcp_get_tools_exports = {};
22
+ __export(mcp_get_tools_exports, {
23
+ default: () => mcp_get_tools_default
24
+ });
25
+ module.exports = __toCommonJS(mcp_get_tools_exports);
26
+
27
+ // src/codemods/lib/create-transformer.ts
28
+ function createTransformer(transformFn) {
29
+ return function transformer(fileInfo, api, options) {
30
+ const j = api.jscodeshift;
31
+ const root = j(fileInfo.source);
32
+ const context = {
33
+ j,
34
+ root,
35
+ hasChanges: false,
36
+ messages: []
37
+ };
38
+ transformFn(fileInfo, api, options, context);
39
+ context.messages.forEach((message) => api.report(message));
40
+ return context.hasChanges ? root.toSource({ quote: "single" }) : null;
41
+ };
42
+ }
43
+
44
+ // src/codemods/v1/mcp-get-tools.ts
45
+ var mcp_get_tools_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ const mcpVariables = /* @__PURE__ */ new Set();
48
+ root.find(j.VariableDeclarator).forEach((path) => {
49
+ const node = path.node;
50
+ if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "MCPServer" && node.id.type === "Identifier") {
51
+ mcpVariables.add(node.id.name);
52
+ }
53
+ });
54
+ if (mcpVariables.size === 0) return;
55
+ root.find(j.CallExpression).forEach((path) => {
56
+ const node = path.node;
57
+ if (node.callee.type !== "MemberExpression") {
58
+ return;
59
+ }
60
+ const callee = node.callee;
61
+ if (callee.object.type !== "Identifier" || !mcpVariables.has(callee.object.name)) {
62
+ return;
63
+ }
64
+ if (callee.property.type !== "Identifier" || callee.property.name !== "getTools") {
65
+ return;
66
+ }
67
+ callee.property.name = "listTools";
68
+ context.hasChanges = true;
69
+ });
70
+ if (context.hasChanges) {
71
+ context.messages.push(`Transformed MCPServer method: getTools \u2192 listTools`);
72
+ }
73
+ });
74
+ //# sourceMappingURL=mcp-get-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/mcp-get-tools.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms MCPServer getTools method to listTools:\n * - mcp.getTools() → mcp.listTools()\n *\n * Only transforms methods on variables that were instantiated with `new MCPServer(...)`\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Track variable names that are MCPServer instances\n const mcpVariables = new Set<string>();\n\n // Find all variable declarations with new MCPServer() assignments\n root.find(j.VariableDeclarator).forEach(path => {\n const node = path.node;\n\n // Check if the init is a new MCPServer() expression\n if (\n node.init &&\n node.init.type === 'NewExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'MCPServer' &&\n node.id.type === 'Identifier'\n ) {\n mcpVariables.add(node.id.name);\n }\n });\n\n // Early return if no MCPServer instances found\n if (mcpVariables.size === 0) return;\n\n // Find all call expressions where the callee is mcp.getTools\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., mcp.getTools)\n if (node.callee.type !== 'MemberExpression') {\n return;\n }\n\n const callee = node.callee;\n\n // Check if the object is a MCPServer variable\n if (callee.object.type !== 'Identifier' || !mcpVariables.has(callee.object.name)) {\n return;\n }\n\n // Check if the property is 'getTools'\n if (callee.property.type !== 'Identifier' || callee.property.name !== 'getTools') {\n return;\n }\n\n // Rename the method to 'listTools'\n callee.property.name = 'listTools';\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed MCPServer method: getTools → listTools`);\n }\n});\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;AACtE,UAAM,IAAI,IAAI;AACd,UAAM,OAAO,EAAE,SAAS,MAAM;AAC9B,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,UAAU,CAAC;AAAA,IACb;AAGA,gBAAY,UAAU,KAAK,SAAS,OAAO;AAG3C,YAAQ,SAAS,QAAQ,aAAW,IAAI,OAAO,OAAO,CAAC;AAGvD,WAAO,QAAQ,aAAa,KAAK,SAAS,EAAE,OAAO,SAAS,CAAC,IAAI;AAAA,EACnE;AACF;;;AD5CA,IAAO,wBAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,eAAe,oBAAI,IAAY;AAGrC,OAAK,KAAK,EAAE,kBAAkB,EAAE,QAAQ,UAAQ;AAC9C,UAAM,OAAO,KAAK;AAGlB,QACE,KAAK,QACL,KAAK,KAAK,SAAS,mBACnB,KAAK,KAAK,OAAO,SAAS,gBAC1B,KAAK,KAAK,OAAO,SAAS,eAC1B,KAAK,GAAG,SAAS,cACjB;AACA,mBAAa,IAAI,KAAK,GAAG,IAAI;AAAA,IAC/B;AAAA,EACF,CAAC;AAGD,MAAI,aAAa,SAAS,EAAG;AAG7B,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,UAAM,OAAO,KAAK;AAGlB,QAAI,KAAK,OAAO,SAAS,oBAAoB;AAC3C;AAAA,IACF;AAEA,UAAM,SAAS,KAAK;AAGpB,QAAI,OAAO,OAAO,SAAS,gBAAgB,CAAC,aAAa,IAAI,OAAO,OAAO,IAAI,GAAG;AAChF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,SAAS,gBAAgB,OAAO,SAAS,SAAS,YAAY;AAChF;AAAA,IACF;AAGA,WAAO,SAAS,OAAO;AACvB,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,yDAAoD;AAAA,EAC5E;AACF,CAAC;","names":[]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/codemods/v1/mcp-get-toolsets.ts
21
+ var mcp_get_toolsets_exports = {};
22
+ __export(mcp_get_toolsets_exports, {
23
+ default: () => mcp_get_toolsets_default
24
+ });
25
+ module.exports = __toCommonJS(mcp_get_toolsets_exports);
26
+
27
+ // src/codemods/lib/create-transformer.ts
28
+ function createTransformer(transformFn) {
29
+ return function transformer(fileInfo, api, options) {
30
+ const j = api.jscodeshift;
31
+ const root = j(fileInfo.source);
32
+ const context = {
33
+ j,
34
+ root,
35
+ hasChanges: false,
36
+ messages: []
37
+ };
38
+ transformFn(fileInfo, api, options, context);
39
+ context.messages.forEach((message) => api.report(message));
40
+ return context.hasChanges ? root.toSource({ quote: "single" }) : null;
41
+ };
42
+ }
43
+
44
+ // src/codemods/v1/mcp-get-toolsets.ts
45
+ var mcp_get_toolsets_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ const mcpVariables = /* @__PURE__ */ new Set();
48
+ root.find(j.VariableDeclarator).forEach((path) => {
49
+ const node = path.node;
50
+ if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "MCPServer" && node.id.type === "Identifier") {
51
+ mcpVariables.add(node.id.name);
52
+ }
53
+ });
54
+ if (mcpVariables.size === 0) return;
55
+ root.find(j.CallExpression).forEach((path) => {
56
+ const node = path.node;
57
+ if (node.callee.type !== "MemberExpression") {
58
+ return;
59
+ }
60
+ const callee = node.callee;
61
+ if (callee.object.type !== "Identifier" || !mcpVariables.has(callee.object.name)) {
62
+ return;
63
+ }
64
+ if (callee.property.type !== "Identifier" || callee.property.name !== "getToolsets") {
65
+ return;
66
+ }
67
+ callee.property.name = "listToolsets";
68
+ context.hasChanges = true;
69
+ });
70
+ if (context.hasChanges) {
71
+ context.messages.push(`Transformed MCPServer method: getToolsets \u2192 listToolsets`);
72
+ }
73
+ });
74
+ //# sourceMappingURL=mcp-get-toolsets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/mcp-get-toolsets.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms MCPServer getToolsets method to listToolsets:\n * - mcp.getToolsets() → mcp.listToolsets()\n *\n * Only transforms methods on variables that were instantiated with `new MCPServer(...)`\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Track variable names that are MCPServer instances\n const mcpVariables = new Set<string>();\n\n // Find all variable declarations with new MCPServer() assignments\n root.find(j.VariableDeclarator).forEach(path => {\n const node = path.node;\n\n // Check if the init is a new MCPServer() expression\n if (\n node.init &&\n node.init.type === 'NewExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'MCPServer' &&\n node.id.type === 'Identifier'\n ) {\n mcpVariables.add(node.id.name);\n }\n });\n\n // Early return if no MCPServer instances found\n if (mcpVariables.size === 0) return;\n\n // Find all call expressions where the callee is mcp.getToolsets\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., mcp.getToolsets)\n if (node.callee.type !== 'MemberExpression') {\n return;\n }\n\n const callee = node.callee;\n\n // Check if the object is a MCPServer variable\n if (callee.object.type !== 'Identifier' || !mcpVariables.has(callee.object.name)) {\n return;\n }\n\n // Check if the property is 'getToolsets'\n if (callee.property.type !== 'Identifier' || callee.property.name !== 'getToolsets') {\n return;\n }\n\n // Rename the method to 'listToolsets'\n callee.property.name = 'listToolsets';\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed MCPServer method: getToolsets → listToolsets`);\n }\n});\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;AACtE,UAAM,IAAI,IAAI;AACd,UAAM,OAAO,EAAE,SAAS,MAAM;AAC9B,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,UAAU,CAAC;AAAA,IACb;AAGA,gBAAY,UAAU,KAAK,SAAS,OAAO;AAG3C,YAAQ,SAAS,QAAQ,aAAW,IAAI,OAAO,OAAO,CAAC;AAGvD,WAAO,QAAQ,aAAa,KAAK,SAAS,EAAE,OAAO,SAAS,CAAC,IAAI;AAAA,EACnE;AACF;;;AD5CA,IAAO,2BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,eAAe,oBAAI,IAAY;AAGrC,OAAK,KAAK,EAAE,kBAAkB,EAAE,QAAQ,UAAQ;AAC9C,UAAM,OAAO,KAAK;AAGlB,QACE,KAAK,QACL,KAAK,KAAK,SAAS,mBACnB,KAAK,KAAK,OAAO,SAAS,gBAC1B,KAAK,KAAK,OAAO,SAAS,eAC1B,KAAK,GAAG,SAAS,cACjB;AACA,mBAAa,IAAI,KAAK,GAAG,IAAI;AAAA,IAC/B;AAAA,EACF,CAAC;AAGD,MAAI,aAAa,SAAS,EAAG;AAG7B,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,UAAM,OAAO,KAAK;AAGlB,QAAI,KAAK,OAAO,SAAS,oBAAoB;AAC3C;AAAA,IACF;AAEA,UAAM,SAAS,KAAK;AAGpB,QAAI,OAAO,OAAO,SAAS,gBAAgB,CAAC,aAAa,IAAI,OAAO,OAAO,IAAI,GAAG;AAChF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,SAAS,gBAAgB,OAAO,SAAS,SAAS,eAAe;AACnF;AAAA,IACF;AAGA,WAAO,SAAS,OAAO;AACvB,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,+DAA0D;AAAA,EAClF;AACF,CAAC;","names":[]}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/codemods/v1/voice-property-names.ts
21
+ var voice_property_names_exports = {};
22
+ __export(voice_property_names_exports, {
23
+ default: () => voice_property_names_default
24
+ });
25
+ module.exports = __toCommonJS(voice_property_names_exports);
26
+
27
+ // src/codemods/lib/create-transformer.ts
28
+ function createTransformer(transformFn) {
29
+ return function transformer(fileInfo, api, options) {
30
+ const j = api.jscodeshift;
31
+ const root = j(fileInfo.source);
32
+ const context = {
33
+ j,
34
+ root,
35
+ hasChanges: false,
36
+ messages: []
37
+ };
38
+ transformFn(fileInfo, api, options, context);
39
+ context.messages.forEach((message) => api.report(message));
40
+ return context.hasChanges ? root.toSource({ quote: "single" }) : null;
41
+ };
42
+ }
43
+
44
+ // src/codemods/v1/voice-property-names.ts
45
+ var voice_property_names_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ const propertyRenames = {
48
+ speakProvider: "output",
49
+ listenProvider: "input",
50
+ realtimeProvider: "realtime"
51
+ };
52
+ root.find(j.NewExpression, {
53
+ callee: { type: "Identifier", name: "Agent" }
54
+ }).forEach((agentPath) => {
55
+ const configArg = agentPath.node.arguments[0];
56
+ if (!configArg || configArg.type !== "ObjectExpression") return;
57
+ configArg.properties?.forEach((prop) => {
58
+ if ((prop.type === "Property" || prop.type === "ObjectProperty") && prop.key.type === "Identifier" && prop.key.name === "voice" && prop.value.type === "ObjectExpression") {
59
+ prop.value.properties?.forEach((voiceProp) => {
60
+ if ((voiceProp.type === "Property" || voiceProp.type === "ObjectProperty") && voiceProp.key.type === "Identifier") {
61
+ const oldName = voiceProp.key.name;
62
+ const newName = propertyRenames[oldName];
63
+ if (newName) {
64
+ voiceProp.key.name = newName;
65
+ context.hasChanges = true;
66
+ }
67
+ }
68
+ });
69
+ }
70
+ });
71
+ });
72
+ if (context.hasChanges) {
73
+ context.messages.push(
74
+ `Transformed voice property names: speakProvider/listenProvider/realtimeProvider \u2192 output/input/realtime`
75
+ );
76
+ }
77
+ });
78
+ //# sourceMappingURL=voice-property-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/voice-property-names.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms voice property names in Agent configuration:\n * - speakProvider → output\n * - listenProvider → input\n * - realtimeProvider → realtime\n *\n * Only transforms properties within new Agent({ voice: { ... } })\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Map of old property names to new property names\n const propertyRenames: Record<string, string> = {\n speakProvider: 'output',\n listenProvider: 'input',\n realtimeProvider: 'realtime',\n };\n\n // Find all new Agent({ ... }) expressions\n root\n .find(j.NewExpression, {\n callee: { type: 'Identifier', name: 'Agent' },\n })\n .forEach(agentPath => {\n const configArg = agentPath.node.arguments[0];\n if (!configArg || configArg.type !== 'ObjectExpression') return;\n\n // Find the voice property in the Agent config object\n configArg.properties?.forEach((prop: any) => {\n if (\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'voice' &&\n prop.value.type === 'ObjectExpression'\n ) {\n // Now rename properties within the voice object\n prop.value.properties?.forEach((voiceProp: any) => {\n if (\n (voiceProp.type === 'Property' || voiceProp.type === 'ObjectProperty') &&\n voiceProp.key.type === 'Identifier'\n ) {\n const oldName = voiceProp.key.name;\n const newName = propertyRenames[oldName];\n\n if (newName) {\n voiceProp.key.name = newName;\n context.hasChanges = true;\n }\n }\n });\n }\n });\n });\n\n if (context.hasChanges) {\n context.messages.push(\n `Transformed voice property names: speakProvider/listenProvider/realtimeProvider → output/input/realtime`,\n );\n }\n});\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;AACtE,UAAM,IAAI,IAAI;AACd,UAAM,OAAO,EAAE,SAAS,MAAM;AAC9B,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,UAAU,CAAC;AAAA,IACb;AAGA,gBAAY,UAAU,KAAK,SAAS,OAAO;AAG3C,YAAQ,SAAS,QAAQ,aAAW,IAAI,OAAO,OAAO,CAAC;AAGvD,WAAO,QAAQ,aAAa,KAAK,SAAS,EAAE,OAAO,SAAS,CAAC,IAAI;AAAA,EACnE;AACF;;;AD1CA,IAAO,+BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,kBAA0C;AAAA,IAC9C,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,EACpB;AAGA,OACG,KAAK,EAAE,eAAe;AAAA,IACrB,QAAQ,EAAE,MAAM,cAAc,MAAM,QAAQ;AAAA,EAC9C,CAAC,EACA,QAAQ,eAAa;AACpB,UAAM,YAAY,UAAU,KAAK,UAAU,CAAC;AAC5C,QAAI,CAAC,aAAa,UAAU,SAAS,mBAAoB;AAGzD,cAAU,YAAY,QAAQ,CAAC,SAAc;AAC3C,WACG,KAAK,SAAS,cAAc,KAAK,SAAS,qBAC3C,KAAK,IAAI,SAAS,gBAClB,KAAK,IAAI,SAAS,WAClB,KAAK,MAAM,SAAS,oBACpB;AAEA,aAAK,MAAM,YAAY,QAAQ,CAAC,cAAmB;AACjD,eACG,UAAU,SAAS,cAAc,UAAU,SAAS,qBACrD,UAAU,IAAI,SAAS,cACvB;AACA,kBAAM,UAAU,UAAU,IAAI;AAC9B,kBAAM,UAAU,gBAAgB,OAAO;AAEvC,gBAAI,SAAS;AACX,wBAAU,IAAI,OAAO;AACrB,sBAAQ,aAAa;AAAA,YACvB;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAEH,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/codemods/v1/workflows-get-workflows.ts
21
+ var workflows_get_workflows_exports = {};
22
+ __export(workflows_get_workflows_exports, {
23
+ default: () => workflows_get_workflows_default
24
+ });
25
+ module.exports = __toCommonJS(workflows_get_workflows_exports);
26
+
27
+ // src/codemods/lib/create-transformer.ts
28
+ function createTransformer(transformFn) {
29
+ return function transformer(fileInfo, api, options) {
30
+ const j = api.jscodeshift;
31
+ const root = j(fileInfo.source);
32
+ const context = {
33
+ j,
34
+ root,
35
+ hasChanges: false,
36
+ messages: []
37
+ };
38
+ transformFn(fileInfo, api, options, context);
39
+ context.messages.forEach((message) => api.report(message));
40
+ return context.hasChanges ? root.toSource({ quote: "single" }) : null;
41
+ };
42
+ }
43
+
44
+ // src/codemods/v1/workflows-get-workflows.ts
45
+ var workflows_get_workflows_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ const mastraVariables = /* @__PURE__ */ new Set();
48
+ root.find(j.VariableDeclarator).forEach((path) => {
49
+ const node = path.node;
50
+ if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Mastra" && node.id.type === "Identifier") {
51
+ mastraVariables.add(node.id.name);
52
+ }
53
+ });
54
+ if (mastraVariables.size === 0) return;
55
+ root.find(j.CallExpression).forEach((path) => {
56
+ const node = path.node;
57
+ if (node.callee.type !== "MemberExpression") {
58
+ return;
59
+ }
60
+ const callee = node.callee;
61
+ if (callee.object.type !== "Identifier" || !mastraVariables.has(callee.object.name)) {
62
+ return;
63
+ }
64
+ if (callee.property.type !== "Identifier" || callee.property.name !== "getWorkflows") {
65
+ return;
66
+ }
67
+ callee.property.name = "listWorkflows";
68
+ context.hasChanges = true;
69
+ });
70
+ if (context.hasChanges) {
71
+ context.messages.push(`Transformed Mastra method: getWorkflows \u2192 listWorkflows`);
72
+ }
73
+ });
74
+ //# sourceMappingURL=workflows-get-workflows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/workflows-get-workflows.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms Mastra getWorkflows method to listWorkflows:\n * - mastra.getWorkflows() → mastra.listWorkflows()\n *\n * Only transforms methods on variables that were instantiated with `new Mastra(...)`\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Track variable names that are Mastra instances\n const mastraVariables = new Set<string>();\n\n // Find all variable declarations with new Mastra() assignments\n root.find(j.VariableDeclarator).forEach(path => {\n const node = path.node;\n\n // Check if the init is a new Mastra() expression\n if (\n node.init &&\n node.init.type === 'NewExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'Mastra' &&\n node.id.type === 'Identifier'\n ) {\n mastraVariables.add(node.id.name);\n }\n });\n\n // Early return if no Mastra instances found\n if (mastraVariables.size === 0) return;\n\n // Find all call expressions where the callee is mastra.getWorkflows\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., mastra.getWorkflows)\n if (node.callee.type !== 'MemberExpression') {\n return;\n }\n\n const callee = node.callee;\n\n // Check if the object is a Mastra variable\n if (callee.object.type !== 'Identifier' || !mastraVariables.has(callee.object.name)) {\n return;\n }\n\n // Check if the property is 'getWorkflows'\n if (callee.property.type !== 'Identifier' || callee.property.name !== 'getWorkflows') {\n return;\n }\n\n // Rename the method to 'listWorkflows'\n callee.property.name = 'listWorkflows';\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed Mastra method: getWorkflows → listWorkflows`);\n }\n});\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;AACtE,UAAM,IAAI,IAAI;AACd,UAAM,OAAO,EAAE,SAAS,MAAM;AAC9B,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,UAAU,CAAC;AAAA,IACb;AAGA,gBAAY,UAAU,KAAK,SAAS,OAAO;AAG3C,YAAQ,SAAS,QAAQ,aAAW,IAAI,OAAO,OAAO,CAAC;AAGvD,WAAO,QAAQ,aAAa,KAAK,SAAS,EAAE,OAAO,SAAS,CAAC,IAAI;AAAA,EACnE;AACF;;;AD5CA,IAAO,kCAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,kBAAkB,oBAAI,IAAY;AAGxC,OAAK,KAAK,EAAE,kBAAkB,EAAE,QAAQ,UAAQ;AAC9C,UAAM,OAAO,KAAK;AAGlB,QACE,KAAK,QACL,KAAK,KAAK,SAAS,mBACnB,KAAK,KAAK,OAAO,SAAS,gBAC1B,KAAK,KAAK,OAAO,SAAS,YAC1B,KAAK,GAAG,SAAS,cACjB;AACA,sBAAgB,IAAI,KAAK,GAAG,IAAI;AAAA,IAClC;AAAA,EACF,CAAC;AAGD,MAAI,gBAAgB,SAAS,EAAG;AAGhC,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,UAAM,OAAO,KAAK;AAGlB,QAAI,KAAK,OAAO,SAAS,oBAAoB;AAC3C;AAAA,IACF;AAEA,UAAM,SAAS,KAAK;AAGpB,QAAI,OAAO,OAAO,SAAS,gBAAgB,CAAC,gBAAgB,I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