@mastra/codemod 0.0.0-main-test-05-11-2025-2-20251106011400 → 0.0.0-main-test-05-11-2025-2-20251106022801

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 +1 -1
  2. package/README.md +22 -4
  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
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mastra/codemod
2
2
 
3
- ## 0.0.0-main-test-05-11-2025-2-20251106011400
3
+ ## 0.0.0-main-test-05-11-2025-2-20251106022801
4
4
 
5
5
  ### Minor Changes
6
6
 
package/README.md CHANGED
@@ -6,6 +6,12 @@ Codemods are transformations that run on your codebase programmatically, allowin
6
6
 
7
7
  ## Quick Start
8
8
 
9
+ ### Run Version-Specific Codemods
10
+
11
+ ```sh
12
+ npx @mastra/codemod v1
13
+ ```
14
+
9
15
  ### Run Individual Codemods
10
16
 
11
17
  To run a specific codemod:
@@ -31,10 +37,22 @@ npx @mastra/codemod v1/mastra-core-imports .
31
37
 
32
38
  ### v1 Codemods (v0 → v1 Migration)
33
39
 
34
- | Codemod | Description |
35
- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
36
- | `v1/mastra-core-imports` | Updates all imports from `@mastra/core` to use the new subpath imports. For v1, all exports except `Mastra` and `Config` have moved to subpaths. |
37
- | `v1/runtime-context` | Update `RuntimeContext` to `RequestContext` and rename all instances of parameter names. |
40
+ | Codemod | Description |
41
+ | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42
+ | `v1/mastra-core-imports` | Updates all imports from `@mastra/core` to use the new subpath imports. For v1, all exports except `Mastra` and `Config` have moved to subpaths. |
43
+ | `v1/runtime-context` | Renames `RuntimeContext` to `RequestContext` and updates all parameter names from `runtimeContext` to `requestContext` across all APIs, including string literals in middleware. |
44
+ | `v1/agent-generate-stream-v-next` | Transforms Agent VNext methods: `agent.generateVNext()` → `agent.generate()` and `agent.streamVNext()` → `agent.stream()` |
45
+ | `v1/agent-get-agents` | Transforms Mastra method: `mastra.getAgents()` → `mastra.listAgents()` |
46
+ | `v1/agent-processor-methods` | Transforms Agent processor methods: `agent.getInputProcessors()` → `agent.listInputProcessors()` and `agent.getOutputProcessors()` → `agent.listOutputProcessors()` |
47
+ | `v1/agent-property-access` | Transforms Agent property access to method calls: `agent.llm` → `agent.getLLM()`, `agent.tools` → `agent.getTools()`, `agent.instructions` → `agent.getInstructions()` |
48
+ | `v1/agent-voice` | Transforms Agent voice methods to use namespace: `agent.speak()` → `agent.voice.speak()`, `agent.listen()` → `agent.voice.listen()`, `agent.getSpeakers()` → `agent.voice.getSpeakers()` |
49
+ | `v1/evals-get-scorers` | Transforms Mastra method: `mastra.getScorers()` → `mastra.listScorers()` |
50
+ | `v1/experimental-auth` | Renames `experimental_auth` to `auth` in Mastra configuration |
51
+ | `v1/mcp-get-mcp-servers` | Transforms Mastra method: `mastra.getMCPServers()` → `mastra.listMCPServers()` |
52
+ | `v1/mcp-get-tools` | Transforms MCPServer method: `mcp.getTools()` → `mcp.listTools()` |
53
+ | `v1/mcp-get-toolsets` | Transforms MCPServer method: `mcp.getToolsets()` → `mcp.listToolsets()` |
54
+ | `v1/voice-property-names` | Transforms voice property names in Agent configuration: `speakProvider` → `output`, `listenProvider` → `input`, `realtimeProvider` → `realtime` |
55
+ | `v1/workflows-get-workflows` | Transforms Mastra method: `mastra.getWorkflows()` → `mastra.listWorkflows()` |
38
56
 
39
57
  ## CLI Options
40
58
 
@@ -0,0 +1,83 @@
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/agent-generate-stream-v-next.ts
21
+ var agent_generate_stream_v_next_exports = {};
22
+ __export(agent_generate_stream_v_next_exports, {
23
+ default: () => agent_generate_stream_v_next_default
24
+ });
25
+ module.exports = __toCommonJS(agent_generate_stream_v_next_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/agent-generate-stream-v-next.ts
45
+ var agent_generate_stream_v_next_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ const methodRenames = {
48
+ generateVNext: "generate",
49
+ streamVNext: "stream"
50
+ };
51
+ const agentVariables = /* @__PURE__ */ new Set();
52
+ root.find(j.VariableDeclarator).forEach((path) => {
53
+ const node = path.node;
54
+ if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Agent" && node.id.type === "Identifier") {
55
+ agentVariables.add(node.id.name);
56
+ }
57
+ });
58
+ if (agentVariables.size === 0) return;
59
+ root.find(j.CallExpression).forEach((path) => {
60
+ const node = path.node;
61
+ if (node.callee.type !== "MemberExpression") {
62
+ return;
63
+ }
64
+ const callee = node.callee;
65
+ if (callee.object.type !== "Identifier" || !agentVariables.has(callee.object.name)) {
66
+ return;
67
+ }
68
+ if (callee.property.type !== "Identifier") {
69
+ return;
70
+ }
71
+ const oldMethodName = callee.property.name;
72
+ const newMethodName = methodRenames[oldMethodName];
73
+ if (!newMethodName) {
74
+ return;
75
+ }
76
+ callee.property.name = newMethodName;
77
+ context.hasChanges = true;
78
+ });
79
+ if (context.hasChanges) {
80
+ context.messages.push(`Transformed Agent VNext methods: generateVNext/streamVNext \u2192 generate/stream`);
81
+ }
82
+ });
83
+ //# sourceMappingURL=agent-generate-stream-v-next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/agent-generate-stream-v-next.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms Agent VNext methods to their standard names:\n * - agent.generateVNext() → agent.generate()\n * - agent.streamVNext() → agent.stream()\n *\n * Only transforms methods 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 old method names to new method names\n const methodRenames: Record<string, string> = {\n generateVNext: 'generate',\n streamVNext: 'stream',\n };\n\n // Track variable names that are Agent instances\n const agentVariables = new Set<string>();\n\n // Find all variable declarations with new Agent() assignments\n root.find(j.VariableDeclarator).forEach(path => {\n const node = path.node;\n\n // Check if the init is a new Agent() expression\n if (\n node.init &&\n node.init.type === 'NewExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'Agent' &&\n node.id.type === 'Identifier'\n ) {\n agentVariables.add(node.id.name);\n }\n });\n\n // Early return if no Agent instances found\n if (agentVariables.size === 0) return;\n\n // Find all call expressions that are agent VNext methods\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., agent.generateVNext)\n if (node.callee.type !== 'MemberExpression') {\n return;\n }\n\n const callee = node.callee;\n\n // Check if the object is an Agent variable\n if (callee.object.type !== 'Identifier' || !agentVariables.has(callee.object.name)) {\n return;\n }\n\n // Check if the property is a VNext method we want to rename\n if (callee.property.type !== 'Identifier') {\n return;\n }\n\n const oldMethodName = callee.property.name;\n const newMethodName = methodRenames[oldMethodName];\n\n if (!newMethodName) {\n return;\n }\n\n // Rename the method\n callee.property.name = newMethodName;\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed Agent VNext methods: generateVNext/streamVNext → generate/stream`);\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;;;AD3CA,IAAO,uCAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,gBAAwC;AAAA,IAC5C,eAAe;AAAA,IACf,aAAa;AAAA,EACf;AAGA,QAAM,iBAAiB,oBAAI,IAAY;AAGvC,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,WAC1B,KAAK,GAAG,SAAS,cACjB;AACA,qBAAe,IAAI,KAAK,GAAG,IAAI;AAAA,IACjC;AAAA,EACF,CAAC;AAGD,MAAI,eAAe,SAAS,EAAG;AAG/B,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,eAAe,IAAI,OAAO,OAAO,IAAI,GAAG;AAClF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,SAAS,cAAc;AACzC;AAAA,IACF;AAEA,UAAM,gBAAgB,OAAO,SAAS;AACtC,UAAM,gBAAgB,cAAc,aAAa;AAEjD,QAAI,CAAC,eAAe;AAClB;AAAA,IACF;AAGA,WAAO,SAAS,OAAO;AACvB,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,mFAA8E;AAAA,EACtG;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/agent-get-agents.ts
21
+ var agent_get_agents_exports = {};
22
+ __export(agent_get_agents_exports, {
23
+ default: () => agent_get_agents_default
24
+ });
25
+ module.exports = __toCommonJS(agent_get_agents_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/agent-get-agents.ts
45
+ var agent_get_agents_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 !== "getAgents") {
65
+ return;
66
+ }
67
+ callee.property.name = "listAgents";
68
+ context.hasChanges = true;
69
+ });
70
+ if (context.hasChanges) {
71
+ context.messages.push(`Transformed Mastra method: getAgents \u2192 listAgents`);
72
+ }
73
+ });
74
+ //# sourceMappingURL=agent-get-agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/agent-get-agents.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms Mastra getAgents method to listAgents:\n * - mastra.getAgents() → mastra.listAgents()\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.getAgents\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., mastra.getAgents)\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 'getAgents'\n if (callee.property.type !== 'Identifier' || callee.property.name !== 'getAgents') {\n return;\n }\n\n // Rename the method to 'listAgents'\n callee.property.name = 'listAgents';\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed Mastra method: getAgents → listAgents`);\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,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,aAAa;AACjF;AAAA,IACF;AAGA,WAAO,SAAS,OAAO;AACvB,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,wDAAmD;AAAA,EAC3E;AACF,CAAC;","names":[]}
@@ -0,0 +1,85 @@
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/agent-processor-methods.ts
21
+ var agent_processor_methods_exports = {};
22
+ __export(agent_processor_methods_exports, {
23
+ default: () => agent_processor_methods_default
24
+ });
25
+ module.exports = __toCommonJS(agent_processor_methods_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/agent-processor-methods.ts
45
+ var agent_processor_methods_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ const methodRenames = {
48
+ getInputProcessors: "listInputProcessors",
49
+ getOutputProcessors: "listOutputProcessors"
50
+ };
51
+ const agentVariables = /* @__PURE__ */ new Set();
52
+ root.find(j.VariableDeclarator).forEach((path) => {
53
+ const node = path.node;
54
+ if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Agent" && node.id.type === "Identifier") {
55
+ agentVariables.add(node.id.name);
56
+ }
57
+ });
58
+ if (agentVariables.size === 0) return;
59
+ root.find(j.CallExpression).forEach((path) => {
60
+ const node = path.node;
61
+ if (node.callee.type !== "MemberExpression") {
62
+ return;
63
+ }
64
+ const callee = node.callee;
65
+ if (callee.object.type !== "Identifier" || !agentVariables.has(callee.object.name)) {
66
+ return;
67
+ }
68
+ if (callee.property.type !== "Identifier") {
69
+ return;
70
+ }
71
+ const oldMethodName = callee.property.name;
72
+ const newMethodName = methodRenames[oldMethodName];
73
+ if (!newMethodName) {
74
+ return;
75
+ }
76
+ callee.property.name = newMethodName;
77
+ context.hasChanges = true;
78
+ });
79
+ if (context.hasChanges) {
80
+ context.messages.push(
81
+ `Transformed Agent processor methods: getInputProcessors/getOutputProcessors \u2192 listInputProcessors/listOutputProcessors`
82
+ );
83
+ }
84
+ });
85
+ //# sourceMappingURL=agent-processor-methods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/agent-processor-methods.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms Agent processor methods:\n * - agent.getInputProcessors() → agent.listInputProcessors()\n * - agent.getOutputProcessors() → agent.listOutputProcessors()\n *\n * Only transforms methods 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 old method names to new method names\n const methodRenames: Record<string, string> = {\n getInputProcessors: 'listInputProcessors',\n getOutputProcessors: 'listOutputProcessors',\n };\n\n // Track variable names that are Agent instances\n const agentVariables = new Set<string>();\n\n // Find all variable declarations with new Agent() assignments\n root.find(j.VariableDeclarator).forEach(path => {\n const node = path.node;\n\n // Check if the init is a new Agent() expression\n if (\n node.init &&\n node.init.type === 'NewExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'Agent' &&\n node.id.type === 'Identifier'\n ) {\n agentVariables.add(node.id.name);\n }\n });\n\n // Early return if no Agent instances found\n if (agentVariables.size === 0) return;\n\n // Find all call expressions that are agent processor methods\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., agent.getInputProcessors)\n if (node.callee.type !== 'MemberExpression') {\n return;\n }\n\n const callee = node.callee;\n\n // Check if the object is an Agent variable\n if (callee.object.type !== 'Identifier' || !agentVariables.has(callee.object.name)) {\n return;\n }\n\n // Check if the property is a processor method we want to rename\n if (callee.property.type !== 'Identifier') {\n return;\n }\n\n const oldMethodName = callee.property.name;\n const newMethodName = methodRenames[oldMethodName];\n\n if (!newMethodName) {\n return;\n }\n\n // Rename the method\n callee.property.name = newMethodName;\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(\n `Transformed Agent processor methods: getInputProcessors/getOutputProcessors → listInputProcessors/listOutputProcessors`,\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;;;AD3CA,IAAO,kCAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,gBAAwC;AAAA,IAC5C,oBAAoB;AAAA,IACpB,qBAAqB;AAAA,EACvB;AAGA,QAAM,iBAAiB,oBAAI,IAAY;AAGvC,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,WAC1B,KAAK,GAAG,SAAS,cACjB;AACA,qBAAe,IAAI,KAAK,GAAG,IAAI;AAAA,IACjC;AAAA,EACF,CAAC;AAGD,MAAI,eAAe,SAAS,EAAG;AAG/B,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,eAAe,IAAI,OAAO,OAAO,IAAI,GAAG;AAClF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,SAAS,cAAc;AACzC;AAAA,IACF;AAEA,UAAM,gBAAgB,OAAO,SAAS;AACtC,UAAM,gBAAgB,cAAc,aAAa;AAEjD,QAAI,CAAC,eAAe;AAClB;AAAA,IACF;AAGA,WAAO,SAAS,OAAO;AACvB,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -0,0 +1,81 @@
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/agent-property-access.ts
21
+ var agent_property_access_exports = {};
22
+ __export(agent_property_access_exports, {
23
+ default: () => agent_property_access_default
24
+ });
25
+ module.exports = __toCommonJS(agent_property_access_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/agent-property-access.ts
45
+ var agent_property_access_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ const propertyToMethod = {
48
+ llm: "getLLM",
49
+ tools: "getTools",
50
+ instructions: "getInstructions"
51
+ };
52
+ const agentVariables = /* @__PURE__ */ new Set();
53
+ root.find(j.VariableDeclarator).forEach((path) => {
54
+ const node = path.node;
55
+ if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Agent" && node.id.type === "Identifier") {
56
+ agentVariables.add(node.id.name);
57
+ }
58
+ });
59
+ if (agentVariables.size === 0) return;
60
+ root.find(j.MemberExpression).forEach((path) => {
61
+ const node = path.node;
62
+ if (node.object.type !== "Identifier" || !agentVariables.has(node.object.name)) {
63
+ return;
64
+ }
65
+ if (node.property.type !== "Identifier") {
66
+ return;
67
+ }
68
+ const propertyName = node.property.name;
69
+ const methodName = propertyToMethod[propertyName];
70
+ if (!methodName) {
71
+ return;
72
+ }
73
+ const callExpression = j.callExpression(j.memberExpression(node.object, j.identifier(methodName)), []);
74
+ j(path).replaceWith(callExpression);
75
+ context.hasChanges = true;
76
+ });
77
+ if (context.hasChanges) {
78
+ context.messages.push(`Transformed Agent property access to method calls`);
79
+ }
80
+ });
81
+ //# sourceMappingURL=agent-property-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/agent-property-access.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\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 = new Set<string>();\n\n // Find all variable declarations with new Agent() assignments\n root.find(j.VariableDeclarator).forEach(path => {\n const node = path.node;\n\n // Check if the init is a new Agent() expression\n if (\n node.init &&\n node.init.type === 'NewExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'Agent' &&\n node.id.type === 'Identifier'\n ) {\n agentVariables.add(node.id.name);\n }\n });\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","// 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,gCAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,mBAA2C;AAAA,IAC/C,KAAK;AAAA,IACL,OAAO;AAAA,IACP,cAAc;AAAA,EAChB;AAGA,QAAM,iBAAiB,oBAAI,IAAY;AAGvC,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,WAC1B,KAAK,GAAG,SAAS,cACjB;AACA,qBAAe,IAAI,KAAK,GAAG,IAAI;AAAA,IACjC;AAAA,EACF,CAAC;AAGD,MAAI,eAAe,SAAS,EAAG;AAG/B,OAAK,KAAK,EAAE,gBAAgB,EAAE,QAAQ,UAAQ;AAC5C,UAAM,OAAO,KAAK;AAGlB,QAAI,KAAK,OAAO,SAAS,gBAAgB,CAAC,eAAe,IAAI,KAAK,OAAO,IAAI,GAAG;AAC9E;AAAA,IACF;AAGA,QAAI,KAAK,SAAS,SAAS,cAAc;AACvC;AAAA,IACF;AAEA,UAAM,eAAe,KAAK,SAAS;AACnC,UAAM,aAAa,iBAAiB,YAAY;AAEhD,QAAI,CAAC,YAAY;AACf;AAAA,IACF;AAGA,UAAM,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,KAAK,QAAQ,EAAE,WAAW,UAAU,CAAC,GAAG,CAAC,CAAC;AAGrG,MAAE,IAAI,EAAE,YAAY,cAAc;AAElC,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,mDAAmD;AAAA,EAC3E;AACF,CAAC;","names":[]}
@@ -0,0 +1,76 @@
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/agent-voice.ts
21
+ var agent_voice_exports = {};
22
+ __export(agent_voice_exports, {
23
+ default: () => agent_voice_default
24
+ });
25
+ module.exports = __toCommonJS(agent_voice_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/agent-voice.ts
45
+ var agent_voice_default = createTransformer((fileInfo, api, options, context) => {
46
+ const { j, root } = context;
47
+ const voiceMethods = /* @__PURE__ */ new Set(["speak", "listen", "getSpeakers"]);
48
+ const agentVariables = /* @__PURE__ */ new Set();
49
+ root.find(j.VariableDeclarator).forEach((path) => {
50
+ const node = path.node;
51
+ if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Agent" && node.id.type === "Identifier") {
52
+ agentVariables.add(node.id.name);
53
+ }
54
+ });
55
+ if (agentVariables.size === 0) return;
56
+ root.find(j.CallExpression).forEach((path) => {
57
+ const node = path.node;
58
+ if (node.callee.type !== "MemberExpression") {
59
+ return;
60
+ }
61
+ const callee = node.callee;
62
+ if (callee.object.type !== "Identifier" || !agentVariables.has(callee.object.name)) {
63
+ return;
64
+ }
65
+ if (callee.property.type !== "Identifier" || !voiceMethods.has(callee.property.name)) {
66
+ return;
67
+ }
68
+ const newCallee = j.memberExpression(j.memberExpression(callee.object, j.identifier("voice")), callee.property);
69
+ node.callee = newCallee;
70
+ context.hasChanges = true;
71
+ });
72
+ if (context.hasChanges) {
73
+ context.messages.push(`Transformed Agent voice methods to use agent.voice namespace`);
74
+ }
75
+ });
76
+ //# sourceMappingURL=agent-voice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/agent-voice.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms Agent voice method calls to use agent.voice namespace.\n * - agent.speak(...) → agent.voice.speak(...)\n * - agent.listen() → agent.voice.listen()\n * - agent.getSpeakers() → agent.voice.getSpeakers()\n *\n * Only transforms methods on variables that were instantiated with `new Agent(...)`\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Voice methods that should be moved to agent.voice\n const voiceMethods = new Set(['speak', 'listen', 'getSpeakers']);\n\n // Track variable names that are Agent instances\n const agentVariables = new Set<string>();\n\n // Find all variable declarations with new Agent() assignments\n root.find(j.VariableDeclarator).forEach(path => {\n const node = path.node;\n\n // Check if the init is a new Agent() expression\n if (\n node.init &&\n node.init.type === 'NewExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'Agent' &&\n node.id.type === 'Identifier'\n ) {\n agentVariables.add(node.id.name);\n }\n });\n\n // Early return if no Agent instances found\n if (agentVariables.size === 0) return;\n\n // Find all call expressions that are agent voice methods\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., agent.speak)\n if (node.callee.type !== 'MemberExpression') {\n return;\n }\n\n const callee = node.callee;\n\n // Check if the object is an Agent variable\n if (callee.object.type !== 'Identifier' || !agentVariables.has(callee.object.name)) {\n return;\n }\n\n // Check if the property is a voice method\n if (callee.property.type !== 'Identifier' || !voiceMethods.has(callee.property.name)) {\n return;\n }\n\n // Transform agent.method() to agent.voice.method()\n const newCallee = j.memberExpression(j.memberExpression(callee.object, j.identifier('voice')), callee.property);\n\n node.callee = newCallee;\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed Agent voice methods to use agent.voice namespace`);\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,sBAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,eAAe,oBAAI,IAAI,CAAC,SAAS,UAAU,aAAa,CAAC;AAG/D,QAAM,iBAAiB,oBAAI,IAAY;AAGvC,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,WAC1B,KAAK,GAAG,SAAS,cACjB;AACA,qBAAe,IAAI,KAAK,GAAG,IAAI;AAAA,IACjC;AAAA,EACF,CAAC;AAGD,MAAI,eAAe,SAAS,EAAG;AAG/B,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,eAAe,IAAI,OAAO,OAAO,IAAI,GAAG;AAClF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,SAAS,gBAAgB,CAAC,aAAa,IAAI,OAAO,SAAS,IAAI,GAAG;AACpF;AAAA,IACF;AAGA,UAAM,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,OAAO,QAAQ,EAAE,WAAW,OAAO,CAAC,GAAG,OAAO,QAAQ;AAE9G,SAAK,SAAS;AACd,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,8DAA8D;AAAA,EACtF;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/evals-get-scorers.ts
21
+ var evals_get_scorers_exports = {};
22
+ __export(evals_get_scorers_exports, {
23
+ default: () => evals_get_scorers_default
24
+ });
25
+ module.exports = __toCommonJS(evals_get_scorers_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/evals-get-scorers.ts
45
+ var evals_get_scorers_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 !== "getScorers") {
65
+ return;
66
+ }
67
+ callee.property.name = "listScorers";
68
+ context.hasChanges = true;
69
+ });
70
+ if (context.hasChanges) {
71
+ context.messages.push(`Transformed Mastra method: getScorers \u2192 listScorers`);
72
+ }
73
+ });
74
+ //# sourceMappingURL=evals-get-scorers.js.map
@@ -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":[]}