@mastra/codemod 0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939 → 0.0.0-fix-10386-preserve-tool-calls-in-convert-aisdk-20251201210222
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 +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import debug from 'debug';
|
|
4
|
-
import fs from 'fs';
|
|
5
4
|
import child_process from 'child_process';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
6
7
|
import { fileURLToPath } from 'url';
|
|
7
8
|
import util from 'util';
|
|
8
|
-
import path from 'path';
|
|
9
9
|
import { intro, spinner, outro } from '@clack/prompts';
|
|
10
10
|
|
|
11
11
|
var exec = util.promisify(child_process.exec);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/transform.ts","../src/lib/bundle.ts","../src/lib/upgrade.ts","../src/index.ts"],"names":["transform","log","debug","error"],"mappings":";;;;;;;;;;AAOA,IAAM,IAAA,GAAO,IAAA,CAAK,SAAA,CAAU,aAAA,CAAc,IAAI,CAAA;AAS9C,IAAM,GAAA,GAAM,MAAM,mBAAmB,CAAA;AACrC,IAAM,KAAA,GAAQ,MAAM,yBAAyB,CAAA;AAC7C,IAAM,UAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAChD,IAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,UAAU,CAAA;AAEzC,SAAS,cAAA,GAAyB;AAChC,EAAA,MAAM,gBAAA,GAAmB,IAAA,CAAK,OAAA,CAAQ,SAAA,EAAW,kCAAkC,CAAA;AACnF,EAA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CAC5D,MAAA,CAAO,aAAA,EAAe,mCAAmC,CAAA,CACzD,MAAA,CAAO,aAAa,mDAAmD,CAAA,CACvE,MAAA,CAAO,6BAAA,EAA+B,sCAAsC,CAAA,CAC5E,MAAA,CAAO,OAAO,OAAA,EAAS,QAAQ,OAAA,KAAY;AAC1C,EAAA,IAAI;AACF,IAAA,MAAM,SAAA,CAAU,OAAA,EAAS,MAAA,EAAQ,OAAO,CAAA;AAAA,EAC1C,SAAS,GAAA,EAAU;AACjB,IAAAC,MAAAA,CAAM,CAAA,oBAAA,EAAuB,GAAG,CAAA,CAAE,CAAA;AAClC,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAC,CAAA;AAEH,OAAA,CACG,OAAA,CAAQ,IAAI,CAAA,CACZ,WAAA,CAAY,oCAAoC,EAChD,MAAA,CAAO,WAAA,EAAa,wCAAwC,CAAA,CAC5D,MAAA,CAAO,aAAA,EAAe,mCAAmC,CAAA,CACzD,MAAA,CAAO,WAAA,EAAa,mDAAmD,CAAA,CACvE,MAAA,CAAO,+BAA+B,sCAAsC,CAAA,CAC5E,MAAA,CAAO,OAAM,OAAA,KAAW;AACvB,EAAA,IAAI;AACF,IAAA,MAAM,UAAU,OAAO,CAAA;AAAA,EACzB,SAAS,GAAA,EAAU;AACjB,IAAAA,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":["import fs from 'fs';\nimport child_process from 'node:child_process';\nimport { fileURLToPath } from 'node:url';\nimport util from 'node:util';\nimport path from 'path';\nimport debug from 'debug';\n\nconst exec = util.promisify(child_process.exec);\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');\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\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 async function transform(\n codemod: string,\n source: string,\n transformOptions: TransformOptions,\n options: { logStatus: boolean } = { logStatus: true },\n): Promise<{ 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 } = await exec(command, { encoding: 'utf8' });\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","// List of all codemods\nexport const BUNDLE = [\n 'v1/mastra-core-imports',\n 'v1/runtime-context',\n 'v1/not-implemented/mastra-memory',\n 'v1/mastra-plural-apis',\n 'v1/not-implemented/mastra-required-id',\n 'v1/agent-property-access',\n 'v1/agent-voice',\n 'v1/agent-processor-methods',\n 'v1/agent-generate-stream-v-next',\n 'v1/agent-abort-signal',\n 'v1/not-implemented/agent-format-parameter',\n 'v1/not-implemented/agent-to-step',\n 'v1/voice-property-names',\n 'v1/mcp-get-tools',\n 'v1/mcp-get-toolsets',\n 'v1/client-sdk-types',\n 'v1/client-to-ai-sdk-format',\n 'v1/client-offset-limit',\n 'v1/client-get-memory-thread',\n 'v1/experimental-auth',\n 'v1/evals-run-experiment',\n 'v1/evals-scorer-by-name',\n 'v1/evals-prebuilt-imports',\n 'v1/workflow-create-run-async',\n 'v1/workflow-run-count',\n 'v1/workflow-list-runs',\n 'v1/memory-query-to-recall',\n 'v1/memory-vector-search-param',\n 'v1/memory-message-v2-type',\n 'v1/storage-get-threads-by-resource',\n 'v1/storage-list-messages-by-id',\n 'v1/storage-postgres-schema-name',\n 'v1/storage-get-messages-paginated',\n 'v1/storage-list-workflow-runs',\n 'v1/vector-pg-constructor',\n];\n","import { spinner, intro, outro } from '@clack/prompts';\nimport debug from 'debug';\nimport { BUNDLE } from './bundle';\nimport type { TransformErrors } from './transform';\nimport { transform } from './transform';\n\ninterface TransformOptions {\n dry?: true;\n print?: true;\n verbose?: true;\n jscodeshift?: string;\n}\n\nconst log = debug('codemod:upgrade');\nconst error = debug('codemod:upgrade:error');\n\n// Extract v1 codemods from the bundle\nconst v1Bundle = BUNDLE.filter(codemod => codemod.startsWith('v1/'));\n\nasync function runCodemods(codemods: string[], options: TransformOptions, versionLabel: string) {\n const cwd = process.cwd();\n intro(`Starting ${versionLabel} codemods`);\n const modCount = codemods.length;\n const s = spinner();\n\n s.start(`Running ${modCount} ${versionLabel} codemods`);\n\n const allErrors: TransformErrors = [];\n let notImplementedAvailable = false;\n let count = 0;\n for (const [_, codemod] of codemods.entries()) {\n const { errors, notImplementedErrors } = await transform(codemod, cwd, options, {\n logStatus: false,\n });\n allErrors.push(...errors);\n if (notImplementedErrors.length > 0) {\n notImplementedAvailable = true;\n }\n count++;\n s.message(`Codemod ${count}/${modCount} (${codemod})`);\n }\n s.stop(`Ran ${count}/${modCount} codemods.`);\n\n if (allErrors.length > 0) {\n log(`Some ${versionLabel} codemods did not apply successfully to all files. Details:`);\n allErrors.forEach(({ transform, filename, summary }) => {\n error(`codemod=${transform}, path=${filename}, summary=${summary}`);\n });\n }\n\n if (notImplementedAvailable) {\n log(\n `Some ${versionLabel} codemods require manual changes. Please search your codebase for \\`FIXME(mastra): \\` comments and follow the instructions to complete the upgrade.`,\n );\n }\n\n outro(`${versionLabel} codemods complete.`);\n}\n\nexport async function upgradeV1(options: TransformOptions) {\n await runCodemods(v1Bundle, options, 'v1');\n}\n","#! /usr/bin/env node\n\nimport { Command } from 'commander';\nimport debug from 'debug';\nimport { transform } from './lib/transform';\nimport { upgradeV1 } from './lib/upgrade';\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(async (codemod, source, options) => {\n try {\n await transform(codemod, source, options);\n } catch (err: any) {\n error(`Error transforming: ${err}`);\n process.exit(1);\n }\n });\n\nprogram\n .command('v1')\n .description('Apply all v1 codemods (v0.x to v1)')\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(async options => {\n try {\n await upgradeV1(options);\n } catch (err: any) {\n error(`Error transforming: ${err}`);\n process.exit(1);\n }\n });\n\nprogram.parse(process.argv);\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/transform.ts","../src/lib/bundle.ts","../src/lib/upgrade.ts","../src/index.ts"],"names":["transform","log","debug","error"],"mappings":";;;;;;;;;;AAOA,IAAM,IAAA,GAAO,IAAA,CAAK,SAAA,CAAU,aAAA,CAAc,IAAI,CAAA;AAS9C,IAAM,GAAA,GAAM,MAAM,mBAAmB,CAAA;AACrC,IAAM,KAAA,GAAQ,MAAM,yBAAyB,CAAA;AAC7C,IAAM,UAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAChD,IAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,UAAU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AAA,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,OAAO,OAAA,EAAS,QAAQ,OAAA,KAAY;AAC1C,EAAA,IAAI;AACF,IAAA,MAAM,SAAA,CAAU,OAAA,EAAS,MAAA,EAAQ,OAAO,CAAA;AAAA,EAC1C,SAAS,GAAA,EAAU;AACjB,IAAAC,MAAAA,CAAM,CAAA,oBAAA,EAAuB,GAAG,CAAA,CAAE,CAAA;AAClC,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAC,CAAA;AAEH,OAAA,CACG,OAAA,CAAQ,IAAI,CAAA,CACZ,WAAA,CAAY,oCAAoC,EAChD,MAAA,CAAO,WAAA,EAAa,wCAAwC,CAAA,CAC5D,MAAA,CAAO,aAAA,EAAe,mCAAmC,CAAA,CACzD,MAAA,CAAO,WAAA,EAAa,mDAAmD,CAAA,CACvE,MAAA,CAAO,+BAA+B,sCAAsC,CAAA,CAC5E,MAAA,CAAO,OAAM,OAAA,KAAW;AACvB,EAAA,IAAI;AACF,IAAA,MAAM,UAAU,OAAO,CAAA;AAAA,EACzB,SAAS,GAAA,EAAU;AACjB,IAAAA,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":["import child_process from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport util from 'node:util';\nimport debug from 'debug';\n\nconst exec = util.promisify(child_process.exec);\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');\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\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 async function transform(\n codemod: string,\n source: string,\n transformOptions: TransformOptions,\n options: { logStatus: boolean } = { logStatus: true },\n): Promise<{ 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 } = await exec(command, { encoding: 'utf8' });\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","// List of all codemods\nexport const BUNDLE = [\n 'v1/mastra-core-imports',\n 'v1/runtime-context',\n 'v1/not-implemented/mastra-memory',\n 'v1/mastra-plural-apis',\n 'v1/not-implemented/mastra-required-id',\n 'v1/agent-property-access',\n 'v1/agent-voice',\n 'v1/agent-processor-methods',\n 'v1/agent-generate-stream-v-next',\n 'v1/agent-abort-signal',\n 'v1/not-implemented/agent-format-parameter',\n 'v1/not-implemented/agent-to-step',\n 'v1/voice-property-names',\n 'v1/mcp-get-tools',\n 'v1/mcp-get-toolsets',\n 'v1/client-sdk-types',\n 'v1/client-to-ai-sdk-format',\n 'v1/client-offset-limit',\n 'v1/client-get-memory-thread',\n 'v1/experimental-auth',\n 'v1/evals-run-experiment',\n 'v1/evals-scorer-by-name',\n 'v1/evals-prebuilt-imports',\n 'v1/workflow-create-run-async',\n 'v1/workflow-run-count',\n 'v1/workflow-list-runs',\n 'v1/memory-query-to-recall',\n 'v1/memory-vector-search-param',\n 'v1/memory-message-v2-type',\n 'v1/storage-get-threads-by-resource',\n 'v1/storage-list-messages-by-id',\n 'v1/storage-postgres-schema-name',\n 'v1/storage-get-messages-paginated',\n 'v1/storage-list-workflow-runs',\n 'v1/vector-pg-constructor',\n];\n","import { spinner, intro, outro } from '@clack/prompts';\nimport debug from 'debug';\nimport { BUNDLE } from './bundle';\nimport type { TransformErrors } from './transform';\nimport { transform } from './transform';\n\ninterface TransformOptions {\n dry?: true;\n print?: true;\n verbose?: true;\n jscodeshift?: string;\n}\n\nconst log = debug('codemod:upgrade');\nconst error = debug('codemod:upgrade:error');\n\n// Extract v1 codemods from the bundle\nconst v1Bundle = BUNDLE.filter(codemod => codemod.startsWith('v1/'));\n\nasync function runCodemods(codemods: string[], options: TransformOptions, versionLabel: string) {\n const cwd = process.cwd();\n intro(`Starting ${versionLabel} codemods`);\n const modCount = codemods.length;\n const s = spinner();\n\n s.start(`Running ${modCount} ${versionLabel} codemods`);\n\n const allErrors: TransformErrors = [];\n let notImplementedAvailable = false;\n let count = 0;\n for (const [_, codemod] of codemods.entries()) {\n const { errors, notImplementedErrors } = await transform(codemod, cwd, options, {\n logStatus: false,\n });\n allErrors.push(...errors);\n if (notImplementedErrors.length > 0) {\n notImplementedAvailable = true;\n }\n count++;\n s.message(`Codemod ${count}/${modCount} (${codemod})`);\n }\n s.stop(`Ran ${count}/${modCount} codemods.`);\n\n if (allErrors.length > 0) {\n log(`Some ${versionLabel} codemods did not apply successfully to all files. Details:`);\n allErrors.forEach(({ transform, filename, summary }) => {\n error(`codemod=${transform}, path=${filename}, summary=${summary}`);\n });\n }\n\n if (notImplementedAvailable) {\n log(\n `Some ${versionLabel} codemods require manual changes. Please search your codebase for \\`FIXME(mastra): \\` comments and follow the instructions to complete the upgrade.`,\n );\n }\n\n outro(`${versionLabel} codemods complete.`);\n}\n\nexport async function upgradeV1(options: TransformOptions) {\n await runCodemods(v1Bundle, options, 'v1');\n}\n","#! /usr/bin/env node\n\nimport { Command } from 'commander';\nimport debug from 'debug';\nimport { transform } from './lib/transform';\nimport { upgradeV1 } from './lib/upgrade';\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(async (codemod, source, options) => {\n try {\n await transform(codemod, source, options);\n } catch (err: any) {\n error(`Error transforming: ${err}`);\n process.exit(1);\n }\n });\n\nprogram\n .command('v1')\n .description('Apply all v1 codemods (v0.x to v1)')\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(async options => {\n try {\n await upgradeV1(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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/codemod",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-fix-
|
|
4
|
+
"version": "0.0.0-fix-10386-preserve-tool-calls-in-convert-aisdk-20251201210222",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Codemod CLI for Mastra",
|
|
7
7
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"tsup": "^8.5.0",
|
|
35
35
|
"typescript": "^5.8.3",
|
|
36
36
|
"vitest": "4.0.12",
|
|
37
|
-
"@internal/lint": "0.0.0-fix-
|
|
37
|
+
"@internal/lint": "0.0.0-fix-10386-preserve-tool-calls-in-convert-aisdk-20251201210222"
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://mastra.ai",
|
|
40
40
|
"repository": {
|