@mastra/codemod 0.0.0-fix-9244-clickhouse-metadata-20251105010900
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.
- package/CHANGELOG.md +7 -0
- package/LICENSE.md +15 -0
- package/README.md +99 -0
- package/dist/codemods/lib/add-comment.js +57 -0
- package/dist/codemods/lib/add-comment.js.map +1 -0
- package/dist/codemods/lib/create-transformer.js +45 -0
- package/dist/codemods/lib/create-transformer.js.map +1 -0
- package/dist/codemods/v1/mastra-core-imports.js +189 -0
- package/dist/codemods/v1/mastra-core-imports.js.map +1 -0
- package/dist/codemods/v1/runtime-context.js +166 -0
- package/dist/codemods/v1/runtime-context.js.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Apache License 2.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Mastra Codemods
|
|
2
|
+
|
|
3
|
+
Mastra provides automated code transformations (codemods) to help upgrade your codebase when features are deprecated, removed, or changed between versions.
|
|
4
|
+
|
|
5
|
+
Codemods are transformations that run on your codebase programmatically, allowing you to apply many changes without manually editing every file.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
### Run Individual Codemods
|
|
10
|
+
|
|
11
|
+
To run a specific codemod:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npx @mastra/codemod <codemod-name> <path>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Examples:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
# Transform a specific file
|
|
21
|
+
npx @mastra/codemod v1/mastra-core-imports src/mastra.ts
|
|
22
|
+
|
|
23
|
+
# Transform a directory
|
|
24
|
+
npx @mastra/codemod v1/mastra-core-imports src/lib/
|
|
25
|
+
|
|
26
|
+
# Transform entire project
|
|
27
|
+
npx @mastra/codemod v1/mastra-core-imports .
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Available Codemods
|
|
31
|
+
|
|
32
|
+
### v1 Codemods (v0 → v1 Migration)
|
|
33
|
+
|
|
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. |
|
|
38
|
+
|
|
39
|
+
## CLI Options
|
|
40
|
+
|
|
41
|
+
### Commands
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npx @mastra/codemod <command> [options]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Available Commands:**
|
|
48
|
+
|
|
49
|
+
- `<codemod-name> <path>` - Apply specific codemod
|
|
50
|
+
|
|
51
|
+
### Global Options
|
|
52
|
+
|
|
53
|
+
- `--dry` - Preview changes without applying them
|
|
54
|
+
- `--print` - Print transformed code to stdout
|
|
55
|
+
- `--verbose` - Show detailed transformation logs
|
|
56
|
+
|
|
57
|
+
### Examples
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
# Show verbose output for specific codemod
|
|
61
|
+
npx @mastra/codemod --verbose v1/mastra-core-imports src/
|
|
62
|
+
|
|
63
|
+
# Print transformed code for specific codemod
|
|
64
|
+
npx @mastra/codemod --print v1/mastra-core-imports src/mastra.ts
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Contributing
|
|
68
|
+
|
|
69
|
+
### Adding New Codemods
|
|
70
|
+
|
|
71
|
+
1. Create the codemod in `src/codemods/<version>`
|
|
72
|
+
2. Add test fixtures in `src/test/__fixtures__/`
|
|
73
|
+
3. Create tests in `src/test/`
|
|
74
|
+
4. Use the scaffold script to generate boilerplate:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
pnpm scaffold
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Testing Codemods
|
|
81
|
+
|
|
82
|
+
First, navigate to the codemod directory:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
cd packages/codemod
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Then run the tests:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
# Run all tests
|
|
92
|
+
pnpm test
|
|
93
|
+
|
|
94
|
+
# Run specific codemod tests
|
|
95
|
+
pnpm test mastra-core-imports
|
|
96
|
+
|
|
97
|
+
# Test in development
|
|
98
|
+
pnpm test:watch
|
|
99
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
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/lib/add-comment.ts
|
|
21
|
+
var add_comment_exports = {};
|
|
22
|
+
__export(add_comment_exports, {
|
|
23
|
+
ERROR_PREFIX: () => ERROR_PREFIX,
|
|
24
|
+
insertCommentOnce: () => insertCommentOnce
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(add_comment_exports);
|
|
27
|
+
var ERROR_PREFIX = "FIXME(mastra): ";
|
|
28
|
+
function existsComment(comments, comment) {
|
|
29
|
+
let hasComment = false;
|
|
30
|
+
if (comments) {
|
|
31
|
+
comments.forEach((commentNode) => {
|
|
32
|
+
const currentComment = commentNode.value.trim();
|
|
33
|
+
if (currentComment === comment) {
|
|
34
|
+
hasComment = true;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (hasComment) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
function insertCommentOnce(node, j, comment) {
|
|
44
|
+
const hasCommentInInlineComments = existsComment(node.comments, comment);
|
|
45
|
+
const hasCommentInLeadingComments = existsComment(node.leadingComments, comment);
|
|
46
|
+
if (!hasCommentInInlineComments && !hasCommentInLeadingComments) {
|
|
47
|
+
node.comments = [...node.comments || [], j.commentBlock(` ${comment} `)];
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
ERROR_PREFIX,
|
|
55
|
+
insertCommentOnce
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=add-comment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/lib/add-comment.ts"],"sourcesContent":["import type { API, ASTPath } from 'jscodeshift';\n\nexport const ERROR_PREFIX = 'FIXME(mastra): ';\n\nfunction existsComment(comments: ASTPath<any>['node']['comments'], comment: string): boolean {\n let hasComment = false;\n\n if (comments) {\n comments.forEach((commentNode: any) => {\n const currentComment = commentNode.value.trim();\n if (currentComment === comment) {\n hasComment = true;\n }\n });\n\n if (hasComment) {\n return true;\n }\n }\n return false;\n}\n\nexport function insertCommentOnce(node: ASTPath<any>['node'], j: API['j'], comment: string): boolean {\n const hasCommentInInlineComments = existsComment(node.comments, comment);\n const hasCommentInLeadingComments = existsComment(node.leadingComments, comment);\n\n if (!hasCommentInInlineComments && !hasCommentInLeadingComments) {\n node.comments = [...(node.comments || []), j.commentBlock(` ${comment} `)];\n return true;\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,eAAe;AAE5B,SAAS,cAAc,UAA4C,SAA0B;AAC3F,MAAI,aAAa;AAEjB,MAAI,UAAU;AACZ,aAAS,QAAQ,CAAC,gBAAqB;AACrC,YAAM,iBAAiB,YAAY,MAAM,KAAK;AAC9C,UAAI,mBAAmB,SAAS;AAC9B,qBAAa;AAAA,MACf;AAAA,IACF,CAAC;AAED,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,kBAAkB,MAA4B,GAAa,SAA0B;AACnG,QAAM,6BAA6B,cAAc,KAAK,UAAU,OAAO;AACvE,QAAM,8BAA8B,cAAc,KAAK,iBAAiB,OAAO;AAE/E,MAAI,CAAC,8BAA8B,CAAC,6BAA6B;AAC/D,SAAK,WAAW,CAAC,GAAI,KAAK,YAAY,CAAC,GAAI,EAAE,aAAa,IAAI,OAAO,GAAG,CAAC;AACzE,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
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/lib/create-transformer.ts
|
|
21
|
+
var create_transformer_exports = {};
|
|
22
|
+
__export(create_transformer_exports, {
|
|
23
|
+
createTransformer: () => createTransformer
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(create_transformer_exports);
|
|
26
|
+
function createTransformer(transformFn) {
|
|
27
|
+
return function transformer(fileInfo, api, options) {
|
|
28
|
+
const j = api.jscodeshift;
|
|
29
|
+
const root = j(fileInfo.source);
|
|
30
|
+
const context = {
|
|
31
|
+
j,
|
|
32
|
+
root,
|
|
33
|
+
hasChanges: false,
|
|
34
|
+
messages: []
|
|
35
|
+
};
|
|
36
|
+
transformFn(fileInfo, api, options, context);
|
|
37
|
+
context.messages.forEach((message) => api.report(message));
|
|
38
|
+
return context.hasChanges ? root.toSource({ quote: "single" }) : null;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
createTransformer
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=create-transformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["// 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;AA6BO,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;","names":[]}
|
|
@@ -0,0 +1,189 @@
|
|
|
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/mastra-core-imports.ts
|
|
21
|
+
var mastra_core_imports_exports = {};
|
|
22
|
+
__export(mastra_core_imports_exports, {
|
|
23
|
+
default: () => mastra_core_imports_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(mastra_core_imports_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/mastra-core-imports.ts
|
|
45
|
+
var EXPORT_TO_SUBPATH = {
|
|
46
|
+
// Agent
|
|
47
|
+
Agent: "@mastra/core/agent",
|
|
48
|
+
// Tools
|
|
49
|
+
createTool: "@mastra/core/tools",
|
|
50
|
+
Tool: "@mastra/core/tools",
|
|
51
|
+
// Workflows
|
|
52
|
+
createWorkflow: "@mastra/core/workflows",
|
|
53
|
+
createStep: "@mastra/core/workflows",
|
|
54
|
+
Workflow: "@mastra/core/workflows",
|
|
55
|
+
Step: "@mastra/core/workflows",
|
|
56
|
+
// Request Context
|
|
57
|
+
RequestContext: "@mastra/core/request-context",
|
|
58
|
+
// Processors
|
|
59
|
+
BatchPartsProcessor: "@mastra/core/processors",
|
|
60
|
+
PIIDetector: "@mastra/core/processors",
|
|
61
|
+
ModerationProcessor: "@mastra/core/processors",
|
|
62
|
+
TokenLimiterProcessor: "@mastra/core/processors",
|
|
63
|
+
Processor: "@mastra/core/processors",
|
|
64
|
+
UnicodeNormalizer: "@mastra/core/processors",
|
|
65
|
+
SystemPromptScrubber: "@mastra/core/processors",
|
|
66
|
+
PromptInjectionDetector: "@mastra/core/processors",
|
|
67
|
+
LanguageDetector: "@mastra/core/processors",
|
|
68
|
+
// Voice
|
|
69
|
+
CompositeVoice: "@mastra/core/voice",
|
|
70
|
+
// Scorers/Evals
|
|
71
|
+
runExperiment: "@mastra/core/scores",
|
|
72
|
+
createScorer: "@mastra/core/scores",
|
|
73
|
+
// Server
|
|
74
|
+
registerApiRoute: "@mastra/core/server",
|
|
75
|
+
// AI Tracing
|
|
76
|
+
DefaultExporter: "@mastra/core/ai-tracing",
|
|
77
|
+
CloudExporter: "@mastra/core/ai-tracing",
|
|
78
|
+
// Streaming
|
|
79
|
+
ChunkType: "@mastra/core/stream",
|
|
80
|
+
MastraMessageV2: "@mastra/core/stream",
|
|
81
|
+
// LLM/Models
|
|
82
|
+
ModelRouterEmbeddingModel: "@mastra/core/llm"
|
|
83
|
+
};
|
|
84
|
+
var mastra_core_imports_default = createTransformer((fileInfo, api, options, context) => {
|
|
85
|
+
const { j, root } = context;
|
|
86
|
+
root.find(j.ImportDeclaration, {
|
|
87
|
+
source: { value: "@mastra/core" }
|
|
88
|
+
}).forEach((importPath) => {
|
|
89
|
+
const node = importPath.node;
|
|
90
|
+
const specifiers = node.specifiers || [];
|
|
91
|
+
const declarationImportKind = node.importKind || "value";
|
|
92
|
+
const { remainingSpecifiers, importsToMove } = categorizeImports(specifiers, declarationImportKind);
|
|
93
|
+
if (importsToMove.length === 0) return;
|
|
94
|
+
context.hasChanges = true;
|
|
95
|
+
const groupedImports = groupImportsBySubpath(importsToMove);
|
|
96
|
+
const newImports = createNewImports(j, groupedImports, context);
|
|
97
|
+
insertImports(j, importPath, newImports);
|
|
98
|
+
updateOriginalImport(j, importPath, node, remainingSpecifiers, context);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
function categorizeImports(specifiers, declarationImportKind) {
|
|
102
|
+
const remainingSpecifiers = [];
|
|
103
|
+
const importsToMove = [];
|
|
104
|
+
specifiers.forEach((specifier) => {
|
|
105
|
+
if (specifier.type !== "ImportSpecifier") {
|
|
106
|
+
remainingSpecifiers.push(specifier);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const imported = specifier.imported;
|
|
110
|
+
const importedName = getImportedName(imported);
|
|
111
|
+
const localName = specifier.local?.name || importedName;
|
|
112
|
+
const specifierImportKind = specifier.importKind || "value";
|
|
113
|
+
const effectiveImportKind = declarationImportKind !== "value" ? declarationImportKind : specifierImportKind;
|
|
114
|
+
const isDeclarationType = declarationImportKind !== "value";
|
|
115
|
+
const newSubpath = EXPORT_TO_SUBPATH[importedName];
|
|
116
|
+
if (newSubpath) {
|
|
117
|
+
importsToMove.push({
|
|
118
|
+
subpath: newSubpath,
|
|
119
|
+
localName,
|
|
120
|
+
importedName,
|
|
121
|
+
importKind: effectiveImportKind,
|
|
122
|
+
isDeclarationType
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
remainingSpecifiers.push(specifier);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return { remainingSpecifiers, importsToMove };
|
|
129
|
+
}
|
|
130
|
+
function getImportedName(imported) {
|
|
131
|
+
if (imported.type === "Identifier") {
|
|
132
|
+
return imported.name;
|
|
133
|
+
}
|
|
134
|
+
return imported.value || "";
|
|
135
|
+
}
|
|
136
|
+
function groupImportsBySubpath(importsToMove) {
|
|
137
|
+
const groupedImports = /* @__PURE__ */ new Map();
|
|
138
|
+
importsToMove.forEach(({ subpath, localName, importedName, importKind, isDeclarationType }) => {
|
|
139
|
+
const key = `${subpath}::${importKind}::${isDeclarationType}`;
|
|
140
|
+
if (!groupedImports.has(key)) {
|
|
141
|
+
groupedImports.set(key, []);
|
|
142
|
+
}
|
|
143
|
+
groupedImports.get(key).push({ localName, importedName, importKind, isDeclarationType });
|
|
144
|
+
});
|
|
145
|
+
return groupedImports;
|
|
146
|
+
}
|
|
147
|
+
function createNewImports(j, groupedImports, context) {
|
|
148
|
+
const newImports = [];
|
|
149
|
+
groupedImports.forEach((imports, key) => {
|
|
150
|
+
const [subpath, importKind] = key.split("::");
|
|
151
|
+
const newSpecifiers = imports.map(({ localName, importedName }) => {
|
|
152
|
+
if (localName === importedName) {
|
|
153
|
+
return j.importSpecifier(j.identifier(importedName));
|
|
154
|
+
} else {
|
|
155
|
+
return j.importSpecifier(j.identifier(importedName), j.identifier(localName));
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const newImport = j.importDeclaration(newSpecifiers, j.stringLiteral(subpath));
|
|
159
|
+
if (importKind !== "value") {
|
|
160
|
+
newImport.importKind = importKind;
|
|
161
|
+
}
|
|
162
|
+
newImports.push(newImport);
|
|
163
|
+
const importList = imports.map((i) => i.importedName).join(", ");
|
|
164
|
+
const kindLabel = importKind !== "value" ? ` (${importKind})` : "";
|
|
165
|
+
context.messages.push(`Moved imports to '${subpath}'${kindLabel}: ${importList}`);
|
|
166
|
+
});
|
|
167
|
+
return newImports;
|
|
168
|
+
}
|
|
169
|
+
function insertImports(j, importPath, newImports) {
|
|
170
|
+
newImports.reverse().forEach((newImport) => {
|
|
171
|
+
j(importPath).insertAfter(newImport);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function updateOriginalImport(j, importPath, node, remainingSpecifiers, context) {
|
|
175
|
+
if (remainingSpecifiers.length > 0) {
|
|
176
|
+
node.specifiers = remainingSpecifiers;
|
|
177
|
+
const remainingList = extractRemainingImportNames(remainingSpecifiers);
|
|
178
|
+
if (remainingList) {
|
|
179
|
+
context.messages.push(`Kept at '@mastra/core': ${remainingList}`);
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
j(importPath).remove();
|
|
183
|
+
context.messages.push(`Removed original '@mastra/core' import (all imports moved to subpaths)`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function extractRemainingImportNames(remainingSpecifiers) {
|
|
187
|
+
return remainingSpecifiers.filter((s) => s.type === "ImportSpecifier").map((s) => s.imported?.name || s.local?.name).filter(Boolean).join(", ");
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=mastra-core-imports.js.map
|
|
@@ -0,0 +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 // AI Tracing\n DefaultExporter: '@mastra/core/ai-tracing',\n CloudExporter: '@mastra/core/ai-tracing',\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,EACjB,eAAe;AAAA;AAAA,EAGf,WAAW;AAAA,EACX,iBAAiB;AAAA;AAAA,EAGjB,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,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":[]}
|
|
@@ -0,0 +1,166 @@
|
|
|
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/runtime-context.ts
|
|
21
|
+
var runtime_context_exports = {};
|
|
22
|
+
__export(runtime_context_exports, {
|
|
23
|
+
default: () => runtime_context_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(runtime_context_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/runtime-context.ts
|
|
45
|
+
var runtime_context_default = createTransformer((fileInfo, api, options, context) => {
|
|
46
|
+
const { j, root } = context;
|
|
47
|
+
let hasRuntimeContextImport = false;
|
|
48
|
+
root.find(j.ImportDeclaration).forEach((importPath) => {
|
|
49
|
+
const node = importPath.node;
|
|
50
|
+
if (node.source.value !== "@mastra/core/runtime-context") return;
|
|
51
|
+
node.source.value = "@mastra/core/request-context";
|
|
52
|
+
context.hasChanges = true;
|
|
53
|
+
node.specifiers?.forEach((specifier) => {
|
|
54
|
+
if (specifier.type !== "ImportSpecifier") return;
|
|
55
|
+
const imported = specifier.imported;
|
|
56
|
+
if (imported.type === "Identifier" && imported.name === "RuntimeContext") {
|
|
57
|
+
hasRuntimeContextImport = true;
|
|
58
|
+
imported.name = "RequestContext";
|
|
59
|
+
context.messages.push(`Updated import: RuntimeContext \u2192 RequestContext from '@mastra/core/request-context'`);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
if (!hasRuntimeContextImport) return;
|
|
64
|
+
renameIdentifiers(j, root, context, "RuntimeContext", "RequestContext", "type");
|
|
65
|
+
renameIdentifiers(j, root, context, "runtimeContext", "requestContext", "variable/parameter");
|
|
66
|
+
renameMiddlewareStringLiterals(j, root, context);
|
|
67
|
+
});
|
|
68
|
+
function renameIdentifiers(j, root, context, oldName, newName, description) {
|
|
69
|
+
const identifiers = root.find(j.Identifier, { name: oldName });
|
|
70
|
+
const count = identifiers.length;
|
|
71
|
+
if (count === 0) return;
|
|
72
|
+
identifiers.forEach((path) => {
|
|
73
|
+
path.node.name = newName;
|
|
74
|
+
});
|
|
75
|
+
context.hasChanges = true;
|
|
76
|
+
context.messages.push(`Renamed ${count} ${oldName} ${description} references to ${newName}`);
|
|
77
|
+
}
|
|
78
|
+
function renameMiddlewareStringLiterals(j, root, context) {
|
|
79
|
+
let stringLiteralCount = 0;
|
|
80
|
+
root.find(j.NewExpression, {
|
|
81
|
+
callee: { type: "Identifier", name: "Mastra" }
|
|
82
|
+
}).forEach((mastraPath) => {
|
|
83
|
+
const configArg = mastraPath.node.arguments[0];
|
|
84
|
+
if (!configArg || configArg.type !== "ObjectExpression") return;
|
|
85
|
+
const contextParamNames = /* @__PURE__ */ new Set();
|
|
86
|
+
stringLiteralCount += processNode(configArg, contextParamNames, context);
|
|
87
|
+
});
|
|
88
|
+
if (stringLiteralCount > 0) {
|
|
89
|
+
context.messages.push(
|
|
90
|
+
`Renamed ${stringLiteralCount} string literal 'runtimeContext' to 'requestContext' in Mastra server.middleware`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function processNode(node, contextParamNames, context) {
|
|
95
|
+
if (!node || typeof node !== "object") return 0;
|
|
96
|
+
let count = 0;
|
|
97
|
+
if (isHandlerProperty(node)) {
|
|
98
|
+
const paramName = extractFirstParamName(node.value);
|
|
99
|
+
if (paramName) {
|
|
100
|
+
contextParamNames.add(paramName);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (isContextGetCall(node, contextParamNames)) {
|
|
104
|
+
if (renameStringLiteralArg(node, context)) {
|
|
105
|
+
count++;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
for (const key in node) {
|
|
109
|
+
if (!shouldProcessKey(key, node)) continue;
|
|
110
|
+
const value = node[key];
|
|
111
|
+
if (Array.isArray(value)) {
|
|
112
|
+
value.forEach((item) => {
|
|
113
|
+
count += processNode(item, contextParamNames, context);
|
|
114
|
+
});
|
|
115
|
+
} else if (value && typeof value === "object") {
|
|
116
|
+
count += processNode(value, contextParamNames, context);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return count;
|
|
120
|
+
}
|
|
121
|
+
function isHandlerProperty(node) {
|
|
122
|
+
return (node.type === "Property" || node.type === "ObjectProperty") && node.key?.name === "handler";
|
|
123
|
+
}
|
|
124
|
+
function extractFirstParamName(handlerValue) {
|
|
125
|
+
if (!handlerValue || handlerValue.type !== "ArrowFunctionExpression" && handlerValue.type !== "FunctionExpression") {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
if (!handlerValue.params || handlerValue.params.length === 0) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const firstParam = handlerValue.params[0];
|
|
132
|
+
if (firstParam?.type === "Identifier") {
|
|
133
|
+
return firstParam.name;
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
function isContextGetCall(node, contextParamNames) {
|
|
138
|
+
if (node.type !== "CallExpression") return false;
|
|
139
|
+
const callee = node.callee;
|
|
140
|
+
if (!callee || callee.type !== "MemberExpression") return false;
|
|
141
|
+
const object = callee.object;
|
|
142
|
+
if (!object || object.type !== "Identifier") return false;
|
|
143
|
+
if (!contextParamNames.has(object.name)) return false;
|
|
144
|
+
const property = callee.property;
|
|
145
|
+
if (!property || property.type !== "Identifier" || property.name !== "get") return false;
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
function renameStringLiteralArg(node, context) {
|
|
149
|
+
const firstArg = node.arguments?.[0];
|
|
150
|
+
if (!firstArg) return false;
|
|
151
|
+
const isRuntimeContextLiteral = firstArg.type === "StringLiteral" && firstArg.value === "runtimeContext" || firstArg.type === "Literal" && firstArg.value === "runtimeContext";
|
|
152
|
+
if (!isRuntimeContextLiteral) return false;
|
|
153
|
+
firstArg.value = "requestContext";
|
|
154
|
+
if (firstArg.extra?.raw) {
|
|
155
|
+
const quote = firstArg.extra.raw.charAt(0);
|
|
156
|
+
firstArg.extra.raw = `${quote}requestContext${quote}`;
|
|
157
|
+
}
|
|
158
|
+
context.hasChanges = true;
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
function shouldProcessKey(key, node) {
|
|
162
|
+
if (!node.hasOwnProperty(key)) return false;
|
|
163
|
+
if (key === "loc" || key === "comments") return false;
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=runtime-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/runtime-context.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * The `RuntimeContext` class has been renamed to `RequestContext`, and all parameter names have been updated from `runtimeContext` to `requestContext` across all APIs.\n */\n\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Track whether RuntimeContext was imported from @mastra/core/runtime-context\n let hasRuntimeContextImport = false;\n\n // 1. Update import declarations from runtime-context to request-context\n root.find(j.ImportDeclaration).forEach(importPath => {\n const node = importPath.node;\n\n // Early return: Only process imports from @mastra/core/runtime-context\n if (node.source.value !== '@mastra/core/runtime-context') return;\n\n // Update the import path\n node.source.value = '@mastra/core/request-context';\n context.hasChanges = true;\n\n // Update RuntimeContext to RequestContext in import specifiers\n node.specifiers?.forEach(specifier => {\n if (specifier.type !== 'ImportSpecifier') return;\n\n const imported = specifier.imported;\n if (imported.type === 'Identifier' && imported.name === 'RuntimeContext') {\n hasRuntimeContextImport = true;\n imported.name = 'RequestContext';\n context.messages.push(`Updated import: RuntimeContext → RequestContext from '@mastra/core/request-context'`);\n }\n });\n });\n\n // Early return: Only proceed if RuntimeContext was imported from Mastra\n if (!hasRuntimeContextImport) return;\n\n // 2. Rename RuntimeContext type/class references\n renameIdentifiers(j, root, context, 'RuntimeContext', 'RequestContext', 'type');\n\n // 3. Rename runtimeContext variable/parameter identifiers\n renameIdentifiers(j, root, context, 'runtimeContext', 'requestContext', 'variable/parameter');\n\n // 4. Rename string literal 'runtimeContext' to 'requestContext' in Mastra middleware\n renameMiddlewareStringLiterals(j, root, context);\n});\n\n/**\n * Helper to rename all occurrences of an identifier\n */\nfunction renameIdentifiers(j: any, root: any, context: any, oldName: string, newName: string, description: string) {\n const identifiers = root.find(j.Identifier, { name: oldName });\n const count = identifiers.length;\n\n if (count === 0) return;\n\n identifiers.forEach((path: any) => {\n path.node.name = newName;\n });\n\n context.hasChanges = true;\n context.messages.push(`Renamed ${count} ${oldName} ${description} references to ${newName}`);\n}\n\n/**\n * Helper to rename 'runtimeContext' string literals in Mastra middleware handlers\n */\nfunction renameMiddlewareStringLiterals(j: any, root: any, context: any) {\n let stringLiteralCount = 0;\n\n // Find all new Mastra({ ... }) expressions\n root\n .find(j.NewExpression, {\n callee: { type: 'Identifier', name: 'Mastra' },\n })\n .forEach((mastraPath: any) => {\n const configArg = mastraPath.node.arguments[0];\n if (!configArg || configArg.type !== 'ObjectExpression') return;\n\n // Process this Mastra config to find and rename context.get() calls\n const contextParamNames = new Set<string>();\n stringLiteralCount += processNode(configArg, contextParamNames, context);\n });\n\n if (stringLiteralCount > 0) {\n context.messages.push(\n `Renamed ${stringLiteralCount} string literal 'runtimeContext' to 'requestContext' in Mastra server.middleware`,\n );\n }\n}\n\n/**\n * Recursively search for handler properties and rename context.get() calls\n */\nfunction processNode(node: any, contextParamNames: Set<string>, context: any): number {\n if (!node || typeof node !== 'object') return 0;\n\n let count = 0;\n\n // Check if this is a handler property\n if (isHandlerProperty(node)) {\n const paramName = extractFirstParamName(node.value);\n if (paramName) {\n contextParamNames.add(paramName);\n }\n }\n\n // Check if this is a context.get('runtimeContext') call\n if (isContextGetCall(node, contextParamNames)) {\n if (renameStringLiteralArg(node, context)) {\n count++;\n }\n }\n\n // Recursively process all object properties\n for (const key in node) {\n if (!shouldProcessKey(key, node)) continue;\n\n const value = node[key];\n if (Array.isArray(value)) {\n value.forEach(item => {\n count += processNode(item, contextParamNames, context);\n });\n } else if (value && typeof value === 'object') {\n count += processNode(value, contextParamNames, context);\n }\n }\n\n return count;\n}\n\n/**\n * Check if a node is a handler property (Property or ObjectProperty with key 'handler')\n */\nfunction isHandlerProperty(node: any): boolean {\n return (node.type === 'Property' || node.type === 'ObjectProperty') && node.key?.name === 'handler';\n}\n\n/**\n * Extract the first parameter name from a function expression\n */\nfunction extractFirstParamName(handlerValue: any): string | null {\n if (\n !handlerValue ||\n (handlerValue.type !== 'ArrowFunctionExpression' && handlerValue.type !== 'FunctionExpression')\n ) {\n return null;\n }\n\n if (!handlerValue.params || handlerValue.params.length === 0) {\n return null;\n }\n\n const firstParam = handlerValue.params[0];\n if (firstParam?.type === 'Identifier') {\n return firstParam.name;\n }\n\n return null;\n}\n\n/**\n * Check if a node is a context.get() call expression\n */\nfunction isContextGetCall(node: any, contextParamNames: Set<string>): boolean {\n if (node.type !== 'CallExpression') return false;\n\n const callee = node.callee;\n if (!callee || callee.type !== 'MemberExpression') return false;\n\n const object = callee.object;\n if (!object || object.type !== 'Identifier') return false;\n\n if (!contextParamNames.has(object.name)) return false;\n\n const property = callee.property;\n if (!property || property.type !== 'Identifier' || property.name !== 'get') return false;\n\n return true;\n}\n\n/**\n * Rename the first string argument from 'runtimeContext' to 'requestContext'\n */\nfunction renameStringLiteralArg(node: any, context: any): boolean {\n const firstArg = node.arguments?.[0];\n if (!firstArg) return false;\n\n const isRuntimeContextLiteral =\n (firstArg.type === 'StringLiteral' && firstArg.value === 'runtimeContext') ||\n (firstArg.type === 'Literal' && firstArg.value === 'runtimeContext');\n\n if (!isRuntimeContextLiteral) return false;\n\n // Rename the value\n firstArg.value = 'requestContext';\n\n // Update the raw value if it exists\n if (firstArg.extra?.raw) {\n const quote = firstArg.extra.raw.charAt(0);\n firstArg.extra.raw = `${quote}requestContext${quote}`;\n }\n\n context.hasChanges = true;\n return true;\n}\n\n/**\n * Check if we should process this object key during recursion\n */\nfunction shouldProcessKey(key: string, node: any): boolean {\n // Skip non-own properties\n if (!node.hasOwnProperty(key)) return false;\n\n // Skip metadata properties that don't contain code\n if (key === 'loc' || key === 'comments') return false;\n\n return true;\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;;;AD9CA,IAAO,0BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,MAAI,0BAA0B;AAG9B,OAAK,KAAK,EAAE,iBAAiB,EAAE,QAAQ,gBAAc;AACnD,UAAM,OAAO,WAAW;AAGxB,QAAI,KAAK,OAAO,UAAU,+BAAgC;AAG1D,SAAK,OAAO,QAAQ;AACpB,YAAQ,aAAa;AAGrB,SAAK,YAAY,QAAQ,eAAa;AACpC,UAAI,UAAU,SAAS,kBAAmB;AAE1C,YAAM,WAAW,UAAU;AAC3B,UAAI,SAAS,SAAS,gBAAgB,SAAS,SAAS,kBAAkB;AACxE,kCAA0B;AAC1B,iBAAS,OAAO;AAChB,gBAAQ,SAAS,KAAK,0FAAqF;AAAA,MAC7G;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAGD,MAAI,CAAC,wBAAyB;AAG9B,oBAAkB,GAAG,MAAM,SAAS,kBAAkB,kBAAkB,MAAM;AAG9E,oBAAkB,GAAG,MAAM,SAAS,kBA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Y,CAAC;AACnC,MAAI,CAAC,SAAU,QAAO;AAEtB,QAAM,0BACH,SAAS,SAAS,mBAAmB,SAAS,UAAU,oBACxD,SAAS,SAAS,aAAa,SAAS,UAAU;AAErD,MAAI,CAAC,wBAAyB,QAAO;AAGrC,WAAS,QAAQ;AAGjB,MAAI,SAAS,OAAO,KAAK;AACvB,UAAM,QAAQ,SAAS,MAAM,IAAI,OAAO,CAAC;AACzC,aAAS,MAAM,MAAM,GAAG,KAAK,iBAAiB,KAAK;AAAA,EACrD;AAEA,UAAQ,aAAa;AACrB,SAAO;AACT;AAKA,SAAS,iBAAiB,KAAa,MAAoB;AAEzD,MAAI,CAAC,KAAK,eAAe,GAAG,EAAG,QAAO;AAGtC,MAAI,QAAQ,SAAS,QAAQ,WAAY,QAAO;AAEhD,SAAO;AACT;","names":[]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var commander = require('commander');
|
|
5
|
+
var debug = require('debug');
|
|
6
|
+
var child_process = require('child_process');
|
|
7
|
+
var fs = require('fs');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var debug__default = /*#__PURE__*/_interopDefault(debug);
|
|
13
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
14
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
15
|
+
|
|
16
|
+
var log = debug__default.default("codemod:transform");
|
|
17
|
+
var error = debug__default.default("codemod:transform:error");
|
|
18
|
+
function getJscodeshift() {
|
|
19
|
+
const localJscodeshift = path__default.default.resolve(__dirname, "../node_modules/.bin/jscodeshift");
|
|
20
|
+
return fs__default.default.existsSync(localJscodeshift) ? localJscodeshift : "jscodeshift";
|
|
21
|
+
}
|
|
22
|
+
function buildCommand(codemodPath, targetPath, jscodeshift, options) {
|
|
23
|
+
let command = `${jscodeshift} -t ${codemodPath} ${targetPath} --parser tsx --ignore-pattern="**/node_modules/**" --ignore-pattern="**/.*/**" --ignore-pattern="**/dist/**" --ignore-pattern="**/build/**" --ignore-pattern="**/*.min.js" --ignore-pattern="**/*.bundle.js"`;
|
|
24
|
+
if (options.dry) {
|
|
25
|
+
command += " --dry";
|
|
26
|
+
}
|
|
27
|
+
if (options.print) {
|
|
28
|
+
command += " --print";
|
|
29
|
+
}
|
|
30
|
+
if (options.verbose) {
|
|
31
|
+
command += " --verbose";
|
|
32
|
+
}
|
|
33
|
+
if (options.jscodeshift) {
|
|
34
|
+
command += ` ${options.jscodeshift}`;
|
|
35
|
+
}
|
|
36
|
+
return command;
|
|
37
|
+
}
|
|
38
|
+
function parseErrors(transform2, output) {
|
|
39
|
+
const errors = [];
|
|
40
|
+
const errorRegex = /ERR (.+) Transformation error/g;
|
|
41
|
+
const syntaxErrorRegex = /SyntaxError: .+/g;
|
|
42
|
+
let match;
|
|
43
|
+
while ((match = errorRegex.exec(output)) !== null) {
|
|
44
|
+
const filename = match[1];
|
|
45
|
+
const syntaxErrorMatch = syntaxErrorRegex.exec(output);
|
|
46
|
+
if (syntaxErrorMatch) {
|
|
47
|
+
const summary = syntaxErrorMatch[0];
|
|
48
|
+
errors.push({ transform: transform2, filename, summary });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return errors;
|
|
52
|
+
}
|
|
53
|
+
function parseNotImplementedErrors(transform2, output) {
|
|
54
|
+
const notImplementedErrors = [];
|
|
55
|
+
const notImplementedRegex = /Not Implemented (.+): (.+)/g;
|
|
56
|
+
let match;
|
|
57
|
+
while ((match = notImplementedRegex.exec(output)) !== null) {
|
|
58
|
+
const filename = match[1];
|
|
59
|
+
const summary = match[2];
|
|
60
|
+
notImplementedErrors.push({ transform: transform2, filename, summary });
|
|
61
|
+
}
|
|
62
|
+
return notImplementedErrors;
|
|
63
|
+
}
|
|
64
|
+
function transform(codemod, source, transformOptions, options = { logStatus: true }) {
|
|
65
|
+
if (options.logStatus) {
|
|
66
|
+
log(`Applying codemod '${codemod}': ${source}`);
|
|
67
|
+
}
|
|
68
|
+
const codemodPath = path__default.default.resolve(__dirname, `./codemods/${codemod}.js`);
|
|
69
|
+
const targetPath = path__default.default.resolve(source);
|
|
70
|
+
const jscodeshift = getJscodeshift();
|
|
71
|
+
const command = buildCommand(codemodPath, targetPath, jscodeshift, transformOptions);
|
|
72
|
+
const stdout = child_process.execSync(command, { encoding: "utf8", stdio: "pipe" });
|
|
73
|
+
const errors = parseErrors(codemod, stdout);
|
|
74
|
+
const notImplementedErrors = parseNotImplementedErrors(codemod, stdout);
|
|
75
|
+
if (options.logStatus) {
|
|
76
|
+
if (errors.length > 0) {
|
|
77
|
+
errors.forEach(({ transform: transform2, filename, summary }) => {
|
|
78
|
+
error(`Error applying codemod [codemod=${transform2}, path=${filename}, summary=${summary}]`);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (notImplementedErrors.length > 0) {
|
|
82
|
+
log(
|
|
83
|
+
`Some files require manual changes. Please search your codebase for \`FIXME(mastra): \` comments and follow the instructions to complete the upgrade.`
|
|
84
|
+
);
|
|
85
|
+
notImplementedErrors.forEach(({ transform: transform2, filename, summary }) => {
|
|
86
|
+
log(`Not Implemented [codemod=${transform2}, path=${filename}, summary=${summary}]`);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { errors, notImplementedErrors };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/index.ts
|
|
94
|
+
var error2 = debug__default.default("codemod:error");
|
|
95
|
+
debug__default.default.enable("codemod:*");
|
|
96
|
+
var program = new commander.Command();
|
|
97
|
+
program.name("codemod").description("CLI for running Mastra codemods").argument("<codemod>", "Codemod to run").argument("<source>", "Path to source files or directory").option("-d, --dry", "Dry run (no changes are made to files)").option("-p, --print", "Print transformed files to stdout").option("--verbose", "Show more information about the transform process").option("-j, --jscodeshift <options>", "Pass options directly to jscodeshift").action((codemod, source, options) => {
|
|
98
|
+
try {
|
|
99
|
+
transform(codemod, source, options);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
error2(`Error transforming: ${err}`);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
program.parse(process.argv);
|
|
106
|
+
//# sourceMappingURL=index.js.map
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/transform.ts","../src/index.ts"],"names":["debug","path","fs","transform","execSync","error","Command"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAM,GAAA,GAAMA,uBAAM,mBAAmB,CAAA;AACrC,IAAM,KAAA,GAAQA,uBAAM,yBAAyB,CAAA;AAE7C,SAAS,cAAA,GAAyB;AAChC,EAAA,MAAM,gBAAA,GAAmBC,qBAAA,CAAK,OAAA,CAAQ,SAAA,EAAW,kCAAkC,CAAA;AACnF,EAAA,OAAOC,mBAAA,CAAG,UAAA,CAAW,gBAAgB,CAAA,GAAI,gBAAA,GAAmB,aAAA;AAC9D;AAEA,SAAS,YAAA,CAAa,WAAA,EAAqB,UAAA,EAAoB,WAAA,EAAqB,OAAA,EAAmC;AAGrH,EAAA,IAAI,UAAU,CAAA,EAAG,WAAW,CAAA,IAAA,EAAO,WAAW,IAAI,UAAU,CAAA,yOAAA,CAAA;AAS5D,EAAA,IAAI,QAAQ,GAAA,EAAK;AACf,IAAA,OAAA,IAAW,QAAA;AAAA,EACb;AAEA,EAAA,IAAI,QAAQ,KAAA,EAAO;AACjB,IAAA,OAAA,IAAW,UAAA;AAAA,EACb;AAEA,EAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,IAAA,OAAA,IAAW,YAAA;AAAA,EACb;AAEA,EAAA,IAAI,QAAQ,WAAA,EAAa;AACvB,IAAA,OAAA,IAAW,CAAA,CAAA,EAAI,QAAQ,WAAW,CAAA,CAAA;AAAA,EACpC;AAEA,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Aa,OAAO,CAAA,CAAA,CAAG,CAAA;AAAA,MACpF,CAAC,CAAA;AAAA,IACH;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,QAAQ,oBAAA,EAAqB;AACxC;;;ACxHA,IAAME,MAAAA,GAAQL,uBAAM,eAAe,CAAA;AACnCA,sBAAAA,CAAM,OAAO,WAAW,CAAA;AAExB,IAAM,OAAA,GAAU,IAAIM,iBAAA,EAAQ;AAE5B,OAAA,CACG,IAAA,CAAK,SAAS,CAAA,CACd,WAAA,CAAY,iCAAiC,CAAA,CAC7C,QAAA,CAAS,WAAA,EAAa,gBAAgB,EACtC,QAAA,CAAS,UAAA,EAAY,mCAAmC,CAAA,CACxD,OAAO,WAAA,EAAa,wCAAwC,CAAA,CAC5D,MAAA,CAAO,aAAA,EAAe,mCAAmC,CAAA,CACzD,MAAA,CAAO,aAAa,mDAAmD,CAAA,CACvE,MAAA,CAAO,6BAAA,EAA+B,sCAAsC,CAAA,CAC5E,MAAA,CAAO,CAAC,OAAA,EAAS,QAAQ,OAAA,KAAY;AACpC,EAAA,IAAI;AACF,IAAA,SAAA,CAAU,OAAA,EAAS,QAAQ,OAAO,CAAA;AAAA,EACpC,SAAS,GAAA,EAAU;AACjB,IAAAD,MAAAA,CAAM,CAAA,oBAAA,EAAuB,GAAG,CAAA,CAAE,CAAA;AAClC,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAC,CAAA;AAEH,OAAA,CAAQ,KAAA,CAAM,QAAQ,IAAI,CAAA","file":"index.js","sourcesContent":["// Adjusted from https://github.com/vercel/ai/blob/main/packages/codemod/src/lib/transform.ts\n// License: Apache-2.0\n\nimport { execSync } from 'child_process';\nimport fs from 'fs';\nimport path from 'path';\nimport debug from 'debug';\n\ninterface TransformOptions {\n dry?: boolean;\n print?: boolean;\n verbose?: boolean;\n jscodeshift?: string;\n}\n\nconst log = debug('codemod:transform');\nconst error = debug('codemod:transform:error');\n\nfunction getJscodeshift(): string {\n const localJscodeshift = path.resolve(__dirname, '../node_modules/.bin/jscodeshift');\n return fs.existsSync(localJscodeshift) ? localJscodeshift : 'jscodeshift';\n}\n\nfunction buildCommand(codemodPath: string, targetPath: string, jscodeshift: string, options: TransformOptions): string {\n // Ignoring everything under `.*/` covers `.mastra/` along with any other\n // framework build related or otherwise intended-to-be-hidden directories.\n let command = `${jscodeshift} -t ${codemodPath} ${targetPath} \\\n --parser tsx \\\n --ignore-pattern=\"**/node_modules/**\" \\\n --ignore-pattern=\"**/.*/**\" \\\n --ignore-pattern=\"**/dist/**\" \\\n --ignore-pattern=\"**/build/**\" \\\n --ignore-pattern=\"**/*.min.js\" \\\n --ignore-pattern=\"**/*.bundle.js\"`;\n\n if (options.dry) {\n command += ' --dry';\n }\n\n if (options.print) {\n command += ' --print';\n }\n\n if (options.verbose) {\n command += ' --verbose';\n }\n\n if (options.jscodeshift) {\n command += ` ${options.jscodeshift}`;\n }\n\n return command;\n}\n\nexport type TransformErrors = {\n transform: string;\n filename: string;\n summary: string;\n}[];\n\nfunction parseErrors(transform: string, output: string): TransformErrors {\n const errors: TransformErrors = [];\n const errorRegex = /ERR (.+) Transformation error/g;\n const syntaxErrorRegex = /SyntaxError: .+/g;\n\n let match;\n while ((match = errorRegex.exec(output)) !== null) {\n const filename = match[1]!;\n const syntaxErrorMatch = syntaxErrorRegex.exec(output);\n if (syntaxErrorMatch) {\n const summary = syntaxErrorMatch[0];\n errors.push({ transform, filename, summary });\n }\n }\n\n return errors;\n}\n\nfunction parseNotImplementedErrors(transform: string, output: string): TransformErrors {\n const notImplementedErrors: TransformErrors = [];\n const notImplementedRegex = /Not Implemented (.+): (.+)/g;\n\n let match;\n while ((match = notImplementedRegex.exec(output)) !== null) {\n const filename = match[1]!;\n const summary = match[2]!;\n notImplementedErrors.push({ transform, filename, summary });\n }\n\n return notImplementedErrors;\n}\n\nexport function transform(\n codemod: string,\n source: string,\n transformOptions: TransformOptions,\n options: { logStatus: boolean } = { logStatus: true },\n): { errors: TransformErrors; notImplementedErrors: TransformErrors } {\n if (options.logStatus) {\n log(`Applying codemod '${codemod}': ${source}`);\n }\n const codemodPath = path.resolve(__dirname, `./codemods/${codemod}.js`);\n const targetPath = path.resolve(source);\n const jscodeshift = getJscodeshift();\n const command = buildCommand(codemodPath, targetPath, jscodeshift, transformOptions);\n const stdout = execSync(command, { encoding: 'utf8', stdio: 'pipe' });\n const errors = parseErrors(codemod, stdout);\n const notImplementedErrors = parseNotImplementedErrors(codemod, stdout);\n if (options.logStatus) {\n if (errors.length > 0) {\n errors.forEach(({ transform, filename, summary }) => {\n error(`Error applying codemod [codemod=${transform}, path=${filename}, summary=${summary}]`);\n });\n }\n\n if (notImplementedErrors.length > 0) {\n log(\n `Some files require manual changes. Please search your codebase for \\`FIXME(mastra): \\` comments and follow the instructions to complete the upgrade.`,\n );\n notImplementedErrors.forEach(({ transform, filename, summary }) => {\n log(`Not Implemented [codemod=${transform}, path=${filename}, summary=${summary}]`);\n });\n }\n }\n\n return { errors, notImplementedErrors };\n}\n","#! /usr/bin/env node\n\nimport { Command } from 'commander';\nimport debug from 'debug';\nimport { transform } from './lib/transform';\n\nconst error = debug('codemod:error');\ndebug.enable('codemod:*');\n\nconst program = new Command();\n\nprogram\n .name('codemod')\n .description('CLI for running Mastra codemods')\n .argument('<codemod>', 'Codemod to run')\n .argument('<source>', 'Path to source files or directory')\n .option('-d, --dry', 'Dry run (no changes are made to files)')\n .option('-p, --print', 'Print transformed files to stdout')\n .option('--verbose', 'Show more information about the transform process')\n .option('-j, --jscodeshift <options>', 'Pass options directly to jscodeshift')\n .action((codemod, source, options) => {\n try {\n transform(codemod, source, options);\n } catch (err: any) {\n error(`Error transforming: ${err}`);\n process.exit(1);\n }\n });\n\nprogram.parse(process.argv);\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mastra/codemod",
|
|
3
|
+
"version": "0.0.0-fix-9244-clickhouse-metadata-20251105010900",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Codemod CLI for Mastra",
|
|
6
|
+
"bin": {
|
|
7
|
+
"codemod": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"CHANGELOG.md"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mastra",
|
|
15
|
+
"cli",
|
|
16
|
+
"ai",
|
|
17
|
+
"codemod"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"commander": "^14.0.2",
|
|
21
|
+
"debug": "^4.4.3",
|
|
22
|
+
"jscodeshift": "^17.3.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@commander-js/extra-typings": "^14.0.0",
|
|
26
|
+
"@types/debug": "^4.1.12",
|
|
27
|
+
"@types/jscodeshift": "^17.3.0",
|
|
28
|
+
"@types/node": "^24.9.2",
|
|
29
|
+
"eslint": "^9.37.0",
|
|
30
|
+
"tsup": "^8.5.0",
|
|
31
|
+
"typescript": "^5.8.3",
|
|
32
|
+
"vitest": "^3.2.4",
|
|
33
|
+
"@internal/lint": "0.0.0-fix-9244-clickhouse-metadata-20251105010900"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://mastra.ai",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
39
|
+
"directory": "packages/codemod"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"dev": "tsup --watch",
|
|
49
|
+
"build": "tsup --silent --config tsup.config.ts",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"test:watch": "vitest watch",
|
|
52
|
+
"typecheck": "tsc --noEmit --incremental",
|
|
53
|
+
"lint": "eslint .",
|
|
54
|
+
"scaffold": "npx tsx scripts/scaffold-codemod.ts"
|
|
55
|
+
}
|
|
56
|
+
}
|