assistant-ui 0.0.92 → 0.0.94
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/dist/codemods/utils/createTransformer.d.ts +17 -13
- package/dist/codemods/utils/createTransformer.d.ts.map +1 -1
- package/dist/codemods/utils/createTransformer.js +18 -15
- package/dist/codemods/utils/createTransformer.js.map +1 -1
- package/dist/codemods/v0-11/content-part-to-message-part.d.ts +3 -1
- package/dist/codemods/v0-11/content-part-to-message-part.d.ts.map +1 -1
- package/dist/codemods/v0-11/content-part-to-message-part.js +98 -135
- package/dist/codemods/v0-11/content-part-to-message-part.js.map +1 -1
- package/dist/codemods/v0-12/assistant-api-to-aui.d.ts +3 -1
- package/dist/codemods/v0-12/assistant-api-to-aui.d.ts.map +1 -1
- package/dist/codemods/v0-12/assistant-api-to-aui.js +126 -213
- package/dist/codemods/v0-12/assistant-api-to-aui.js.map +1 -1
- package/dist/codemods/v0-12/event-names-to-camelcase.d.ts +3 -1
- package/dist/codemods/v0-12/event-names-to-camelcase.d.ts.map +1 -1
- package/dist/codemods/v0-12/event-names-to-camelcase.js +33 -38
- package/dist/codemods/v0-12/event-names-to-camelcase.js.map +1 -1
- package/dist/codemods/v0-12/primitive-if-to-aui-if.d.ts +3 -1
- package/dist/codemods/v0-12/primitive-if-to-aui-if.d.ts.map +1 -1
- package/dist/codemods/v0-12/primitive-if-to-aui-if.js +212 -297
- package/dist/codemods/v0-12/primitive-if-to-aui-if.js.map +1 -1
- package/dist/codemods/v0-8/ui-package-split.d.ts +3 -1
- package/dist/codemods/v0-8/ui-package-split.d.ts.map +1 -1
- package/dist/codemods/v0-8/ui-package-split.js +121 -164
- package/dist/codemods/v0-8/ui-package-split.js.map +1 -1
- package/dist/codemods/v0-9/edge-package-split.d.ts +3 -1
- package/dist/codemods/v0-9/edge-package-split.d.ts.map +1 -1
- package/dist/codemods/v0-9/edge-package-split.js +96 -140
- package/dist/codemods/v0-9/edge-package-split.js.map +1 -1
- package/dist/commands/add.d.ts +16 -12
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +53 -64
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/agent.d.ts +5 -1
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +16 -25
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/create.d.ts +34 -30
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +446 -527
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/info.d.ts +5 -1
- package/dist/commands/info.d.ts.map +1 -1
- package/dist/commands/info.js +233 -314
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/init.d.ts +12 -9
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +98 -107
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp.d.ts +5 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +175 -214
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/update.d.ts +5 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +46 -55
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/upgrade.d.ts +11 -7
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +26 -38
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/create-project.d.ts +24 -21
- package/dist/lib/create-project.d.ts.map +1 -1
- package/dist/lib/create-project.js +227 -297
- package/dist/lib/create-project.js.map +1 -1
- package/dist/lib/install-ai-sdk-lib.d.ts +4 -1
- package/dist/lib/install-ai-sdk-lib.d.ts.map +1 -1
- package/dist/lib/install-ai-sdk-lib.js +12 -8
- package/dist/lib/install-ai-sdk-lib.js.map +1 -1
- package/dist/lib/install-edge-lib.d.ts +4 -1
- package/dist/lib/install-edge-lib.d.ts.map +1 -1
- package/dist/lib/install-edge-lib.js +16 -12
- package/dist/lib/install-edge-lib.js.map +1 -1
- package/dist/lib/install-ui-lib.d.ts +4 -1
- package/dist/lib/install-ui-lib.d.ts.map +1 -1
- package/dist/lib/install-ui-lib.js +12 -8
- package/dist/lib/install-ui-lib.js.map +1 -1
- package/dist/lib/run-spawn.d.ts +7 -4
- package/dist/lib/run-spawn.d.ts.map +1 -1
- package/dist/lib/run-spawn.js +23 -23
- package/dist/lib/run-spawn.js.map +1 -1
- package/dist/lib/transform-options.d.ts +8 -5
- package/dist/lib/transform-options.d.ts.map +1 -1
- package/dist/lib/transform-options.js +0 -2
- package/dist/lib/transform.d.ts +15 -11
- package/dist/lib/transform.d.ts.map +1 -1
- package/dist/lib/transform.js +97 -114
- package/dist/lib/transform.js.map +1 -1
- package/dist/lib/upgrade.d.ts +6 -2
- package/dist/lib/upgrade.d.ts.map +1 -1
- package/dist/lib/upgrade.js +62 -64
- package/dist/lib/upgrade.js.map +1 -1
- package/dist/lib/utils/config.d.ts +21 -18
- package/dist/lib/utils/config.d.ts.map +1 -1
- package/dist/lib/utils/config.js +24 -28
- package/dist/lib/utils/config.js.map +1 -1
- package/dist/lib/utils/file-scanner.d.ts +9 -6
- package/dist/lib/utils/file-scanner.d.ts.map +1 -1
- package/dist/lib/utils/file-scanner.js +44 -51
- package/dist/lib/utils/file-scanner.js.map +1 -1
- package/dist/lib/utils/logger.d.ts +10 -7
- package/dist/lib/utils/logger.d.ts.map +1 -1
- package/dist/lib/utils/logger.js +23 -19
- package/dist/lib/utils/logger.js.map +1 -1
- package/dist/lib/utils/package-installer.d.ts +10 -7
- package/dist/lib/utils/package-installer.d.ts.map +1 -1
- package/dist/lib/utils/package-installer.js +18 -19
- package/dist/lib/utils/package-installer.js.map +1 -1
- package/dist/lib/utils/package-manager.d.ts +10 -7
- package/dist/lib/utils/package-manager.d.ts.map +1 -1
- package/dist/lib/utils/package-manager.js +68 -59
- package/dist/lib/utils/package-manager.js.map +1 -1
- package/package.json +7 -7
- package/src/commands/create.ts +1 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/transform-options.js.map +0 -1
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { API, Collection, FileInfo, JSCodeshift } from "jscodeshift";
|
|
2
|
+
|
|
3
|
+
//#region src/codemods/utils/createTransformer.d.ts
|
|
4
|
+
type TransformerFunction = (context: TransformContext, fileInfo: FileInfo, api: API, options: any) => void;
|
|
5
|
+
interface TransformContext {
|
|
6
|
+
/**
|
|
7
|
+
* The jscodeshift API object.
|
|
8
|
+
*/
|
|
9
|
+
j: JSCodeshift;
|
|
10
|
+
/**
|
|
11
|
+
* The root collection of the AST.
|
|
12
|
+
*/
|
|
13
|
+
root: Collection<any>;
|
|
14
|
+
markAsChanged: () => void;
|
|
13
15
|
}
|
|
14
|
-
|
|
16
|
+
declare function createTransformer(transformFn: TransformerFunction): (fileInfo: FileInfo, api: API, options: any) => string | null;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { TransformContext, TransformerFunction, createTransformer };
|
|
15
19
|
//# sourceMappingURL=createTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTransformer.d.ts","
|
|
1
|
+
{"version":3,"file":"createTransformer.d.ts","names":[],"sources":["../../../src/codemods/utils/createTransformer.ts"],"mappings":";;;KAEY,mBAAA,IACV,OAAA,EAAS,gBAAA,EACT,QAAA,EAAU,QAAA,EACV,GAAA,EAAK,GAAA,EACL,OAAA;AAAA,UAGe,gBAAA;EAPL;;;EAWV,CAAA,EAAG,WAAA;EATO;;;EAcV,IAAA,EAAM,UAAU;EAEhB,aAAA;AAAA;AAAA,iBAGc,iBAAA,CAAkB,WAAA,EAAa,mBAAA,IACjB,QAAA,EAAU,QAAA,EAAU,GAAA,EAAK,GAAA,EAAK,OAAA"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
//#region src/codemods/utils/createTransformer.ts
|
|
2
|
+
function createTransformer(transformFn) {
|
|
3
|
+
return function transformer(fileInfo, api, options) {
|
|
4
|
+
const j = api.jscodeshift;
|
|
5
|
+
const root = j(fileInfo.source);
|
|
6
|
+
let isChanged = false;
|
|
7
|
+
transformFn({
|
|
8
|
+
j,
|
|
9
|
+
root,
|
|
10
|
+
markAsChanged: () => {
|
|
11
|
+
isChanged = true;
|
|
12
|
+
}
|
|
13
|
+
}, fileInfo, api, options);
|
|
14
|
+
return isChanged ? root.toSource() : null;
|
|
15
|
+
};
|
|
16
16
|
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { createTransformer };
|
|
19
|
+
|
|
17
20
|
//# sourceMappingURL=createTransformer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTransformer.js","
|
|
1
|
+
{"version":3,"file":"createTransformer.js","names":[],"sources":["../../../src/codemods/utils/createTransformer.ts"],"sourcesContent":["import type { FileInfo, API, JSCodeshift, Collection } from \"jscodeshift\";\n\nexport type TransformerFunction = (\n context: TransformContext,\n fileInfo: FileInfo,\n api: API,\n options: any,\n) => 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 markAsChanged: () => void;\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n\n let isChanged = false;\n const context: TransformContext = {\n j,\n root,\n markAsChanged: () => {\n isChanged = true;\n },\n };\n\n transformFn(context, fileInfo, api, options);\n return isChanged ? root.toSource() : null;\n };\n}\n"],"mappings":";AAuBA,SAAgB,kBAAkB,aAAkC;CAClE,OAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;EACtE,MAAM,IAAI,IAAI;EACd,MAAM,OAAO,EAAE,SAAS,MAAM;EAE9B,IAAI,YAAY;EAShB,YAAY;GAPV;GACA;GACA,qBAAqB;IACnB,YAAY;GACd;EAGgB,GAAG,UAAU,KAAK,OAAO;EAC3C,OAAO,YAAY,KAAK,SAAS,IAAI;CACvC;AACF"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
//#region src/codemods/v0-11/content-part-to-message-part.d.ts
|
|
1
2
|
declare const migrateContentPartToMessagePart: (fileInfo: import("jscodeshift/src/core").FileInfo, api: import("jscodeshift/src/core").API, options: any) => string | null;
|
|
2
|
-
|
|
3
|
+
//#endregion
|
|
4
|
+
export { migrateContentPartToMessagePart as default };
|
|
3
5
|
//# sourceMappingURL=content-part-to-message-part.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-part-to-message-part.d.ts","
|
|
1
|
+
{"version":3,"file":"content-part-to-message-part.d.ts","names":[],"sources":["../../../src/codemods/v0-11/content-part-to-message-part.ts"],"mappings":";cAuEM,+BAAA,GAA+B,QAAA,iCAAA,QAAA,EAAA,GAAA,iCAAA,GAAA,EAAA,OAAA"}
|
|
@@ -1,141 +1,104 @@
|
|
|
1
1
|
import { createTransformer } from "../utils/createTransformer.js";
|
|
2
|
-
|
|
2
|
+
//#region src/codemods/v0-11/content-part-to-message-part.ts
|
|
3
3
|
const typeRenamingMap = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
useContentPartReasoning: "useMessagePartReasoning",
|
|
51
|
-
useContentPartSource: "useMessagePartSource",
|
|
52
|
-
useContentPartFile: "useMessagePartFile",
|
|
53
|
-
useContentPartImage: "useMessagePartImage",
|
|
54
|
-
useTextContentPart: "useTextMessagePart",
|
|
55
|
-
// Primitive names
|
|
56
|
-
ContentPartPrimitive: "MessagePartPrimitive",
|
|
57
|
-
ContentPartPrimitiveText: "MessagePartPrimitiveText",
|
|
58
|
-
ContentPartPrimitiveImage: "MessagePartPrimitiveImage",
|
|
59
|
-
ContentPartPrimitiveInProgress: "MessagePartPrimitiveInProgress",
|
|
4
|
+
TextContentPart: "TextMessagePart",
|
|
5
|
+
ReasoningContentPart: "ReasoningMessagePart",
|
|
6
|
+
SourceContentPart: "SourceMessagePart",
|
|
7
|
+
ImageContentPart: "ImageMessagePart",
|
|
8
|
+
FileContentPart: "FileMessagePart",
|
|
9
|
+
Unstable_AudioContentPart: "Unstable_AudioMessagePart",
|
|
10
|
+
ToolCallContentPart: "ToolCallMessagePart",
|
|
11
|
+
ContentPartStatus: "MessagePartStatus",
|
|
12
|
+
ToolCallContentPartStatus: "ToolCallMessagePartStatus",
|
|
13
|
+
ThreadUserContentPart: "ThreadUserMessagePart",
|
|
14
|
+
ThreadAssistantContentPart: "ThreadAssistantMessagePart",
|
|
15
|
+
ContentPartRuntime: "MessagePartRuntime",
|
|
16
|
+
ContentPartState: "MessagePartState",
|
|
17
|
+
EmptyContentPartComponent: "EmptyMessagePartComponent",
|
|
18
|
+
TextContentPartComponent: "TextMessagePartComponent",
|
|
19
|
+
ReasoningContentPartComponent: "ReasoningMessagePartComponent",
|
|
20
|
+
SourceContentPartComponent: "SourceMessagePartComponent",
|
|
21
|
+
ImageContentPartComponent: "ImageMessagePartComponent",
|
|
22
|
+
FileContentPartComponent: "FileMessagePartComponent",
|
|
23
|
+
Unstable_AudioContentPartComponent: "Unstable_AudioMessagePartComponent",
|
|
24
|
+
ToolCallContentPartComponent: "ToolCallMessagePartComponent",
|
|
25
|
+
EmptyContentPartProps: "EmptyMessagePartProps",
|
|
26
|
+
TextContentPartProps: "TextMessagePartProps",
|
|
27
|
+
ReasoningContentPartProps: "ReasoningMessagePartProps",
|
|
28
|
+
SourceContentPartProps: "SourceMessagePartProps",
|
|
29
|
+
ImageContentPartProps: "ImageMessagePartProps",
|
|
30
|
+
FileContentPartProps: "FileMessagePartProps",
|
|
31
|
+
Unstable_AudioContentPartProps: "Unstable_AudioMessagePartProps",
|
|
32
|
+
ToolCallContentPartProps: "ToolCallMessagePartProps",
|
|
33
|
+
TextContentPartProvider: "TextMessagePartProvider",
|
|
34
|
+
TextContentPartProviderProps: "TextMessagePartProviderProps",
|
|
35
|
+
ContentPartRuntimeProvider: "MessagePartRuntimeProvider",
|
|
36
|
+
ContentPartContext: "MessagePartContext",
|
|
37
|
+
ContentPartContextValue: "MessagePartContextValue",
|
|
38
|
+
useContentPart: "useMessagePart",
|
|
39
|
+
useContentPartRuntime: "useMessagePartRuntime",
|
|
40
|
+
useContentPartText: "useMessagePartText",
|
|
41
|
+
useContentPartReasoning: "useMessagePartReasoning",
|
|
42
|
+
useContentPartSource: "useMessagePartSource",
|
|
43
|
+
useContentPartFile: "useMessagePartFile",
|
|
44
|
+
useContentPartImage: "useMessagePartImage",
|
|
45
|
+
useTextContentPart: "useTextMessagePart",
|
|
46
|
+
ContentPartPrimitive: "MessagePartPrimitive",
|
|
47
|
+
ContentPartPrimitiveText: "MessagePartPrimitiveText",
|
|
48
|
+
ContentPartPrimitiveImage: "MessagePartPrimitiveImage",
|
|
49
|
+
ContentPartPrimitiveInProgress: "MessagePartPrimitiveInProgress"
|
|
60
50
|
};
|
|
61
51
|
const migrateContentPartToMessagePart = createTransformer(({ j, root, markAsChanged }) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// Update identifier references
|
|
111
|
-
root.find(j.Identifier).forEach((path) => {
|
|
112
|
-
if (path.value.name === oldName) {
|
|
113
|
-
// Skip if this is part of an import declaration (already handled above)
|
|
114
|
-
if (j.ImportSpecifier.check(path.parent.value)) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
// Skip if this is a property key in an object
|
|
118
|
-
if (j.Property.check(path.parent.value) &&
|
|
119
|
-
path.parent.value.key === path.value) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
// Skip if this is a property in a member expression
|
|
123
|
-
if (j.MemberExpression.check(path.parent.value) &&
|
|
124
|
-
path.parent.value.property === path.value) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
path.value.name = newName;
|
|
128
|
-
markAsChanged();
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
// Update JSX element names
|
|
132
|
-
root.find(j.JSXIdentifier).forEach((path) => {
|
|
133
|
-
if (path.value.name === oldName) {
|
|
134
|
-
path.value.name = newName;
|
|
135
|
-
markAsChanged();
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
52
|
+
root.find(j.ImportDeclaration).forEach((path) => {
|
|
53
|
+
const source = path.value.source.value;
|
|
54
|
+
if (typeof source === "string" && source.startsWith("@assistant-ui/")) path.value.specifiers?.forEach((specifier) => {
|
|
55
|
+
if (j.ImportSpecifier.check(specifier)) {
|
|
56
|
+
const oldName = specifier.imported.name;
|
|
57
|
+
if (typeRenamingMap[oldName]) {
|
|
58
|
+
specifier.imported.name = typeRenamingMap[oldName];
|
|
59
|
+
if (specifier.local && specifier.local.name === oldName) specifier.local.name = typeRenamingMap[oldName];
|
|
60
|
+
markAsChanged();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
root.find(j.MemberExpression).forEach((path) => {
|
|
66
|
+
if (path.value.object && path.value.object.name === "MessagePrimitive" && path.value.property && path.value.property.name === "Content") {
|
|
67
|
+
path.value.property.name = "Parts";
|
|
68
|
+
markAsChanged();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
root.find(j.JSXMemberExpression).forEach((path) => {
|
|
72
|
+
if (path.value.object && path.value.object.name === "MessagePrimitive" && path.value.property && path.value.property.name === "Content") {
|
|
73
|
+
path.value.property.name = "Parts";
|
|
74
|
+
markAsChanged();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
Object.entries(typeRenamingMap).forEach(([oldName, newName]) => {
|
|
78
|
+
root.find(j.TSTypeReference).forEach((path) => {
|
|
79
|
+
if (path.value.typeName && path.value.typeName.name === oldName) {
|
|
80
|
+
path.value.typeName.name = newName;
|
|
81
|
+
markAsChanged();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
root.find(j.Identifier).forEach((path) => {
|
|
85
|
+
if (path.value.name === oldName) {
|
|
86
|
+
if (j.ImportSpecifier.check(path.parent.value)) return;
|
|
87
|
+
if (j.Property.check(path.parent.value) && path.parent.value.key === path.value) return;
|
|
88
|
+
if (j.MemberExpression.check(path.parent.value) && path.parent.value.property === path.value) return;
|
|
89
|
+
path.value.name = newName;
|
|
90
|
+
markAsChanged();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
root.find(j.JSXIdentifier).forEach((path) => {
|
|
94
|
+
if (path.value.name === oldName) {
|
|
95
|
+
path.value.name = newName;
|
|
96
|
+
markAsChanged();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
139
100
|
});
|
|
140
|
-
|
|
101
|
+
//#endregion
|
|
102
|
+
export { migrateContentPartToMessagePart as default };
|
|
103
|
+
|
|
141
104
|
//# sourceMappingURL=content-part-to-message-part.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-part-to-message-part.js","
|
|
1
|
+
{"version":3,"file":"content-part-to-message-part.js","names":[],"sources":["../../../src/codemods/v0-11/content-part-to-message-part.ts"],"sourcesContent":["import { createTransformer } from \"../utils/createTransformer\";\n\n// Map of old ContentPart names to new MessagePart names\nconst typeRenamingMap: Record<string, string> = {\n // Core types\n TextContentPart: \"TextMessagePart\",\n ReasoningContentPart: \"ReasoningMessagePart\",\n SourceContentPart: \"SourceMessagePart\",\n ImageContentPart: \"ImageMessagePart\",\n FileContentPart: \"FileMessagePart\",\n Unstable_AudioContentPart: \"Unstable_AudioMessagePart\",\n ToolCallContentPart: \"ToolCallMessagePart\",\n\n // Status types\n ContentPartStatus: \"MessagePartStatus\",\n ToolCallContentPartStatus: \"ToolCallMessagePartStatus\",\n\n // Thread message parts\n ThreadUserContentPart: \"ThreadUserMessagePart\",\n ThreadAssistantContentPart: \"ThreadAssistantMessagePart\",\n\n // Runtime and state types\n ContentPartRuntime: \"MessagePartRuntime\",\n ContentPartState: \"MessagePartState\",\n\n // Component types\n EmptyContentPartComponent: \"EmptyMessagePartComponent\",\n TextContentPartComponent: \"TextMessagePartComponent\",\n ReasoningContentPartComponent: \"ReasoningMessagePartComponent\",\n SourceContentPartComponent: \"SourceMessagePartComponent\",\n ImageContentPartComponent: \"ImageMessagePartComponent\",\n FileContentPartComponent: \"FileMessagePartComponent\",\n Unstable_AudioContentPartComponent: \"Unstable_AudioMessagePartComponent\",\n ToolCallContentPartComponent: \"ToolCallMessagePartComponent\",\n\n // Props types\n EmptyContentPartProps: \"EmptyMessagePartProps\",\n TextContentPartProps: \"TextMessagePartProps\",\n ReasoningContentPartProps: \"ReasoningMessagePartProps\",\n SourceContentPartProps: \"SourceMessagePartProps\",\n ImageContentPartProps: \"ImageMessagePartProps\",\n FileContentPartProps: \"FileMessagePartProps\",\n Unstable_AudioContentPartProps: \"Unstable_AudioMessagePartProps\",\n ToolCallContentPartProps: \"ToolCallMessagePartProps\",\n\n // Provider types\n TextContentPartProvider: \"TextMessagePartProvider\",\n TextContentPartProviderProps: \"TextMessagePartProviderProps\",\n ContentPartRuntimeProvider: \"MessagePartRuntimeProvider\",\n\n // Context types\n ContentPartContext: \"MessagePartContext\",\n ContentPartContextValue: \"MessagePartContextValue\",\n\n // Hook names\n useContentPart: \"useMessagePart\",\n useContentPartRuntime: \"useMessagePartRuntime\",\n useContentPartText: \"useMessagePartText\",\n useContentPartReasoning: \"useMessagePartReasoning\",\n useContentPartSource: \"useMessagePartSource\",\n useContentPartFile: \"useMessagePartFile\",\n useContentPartImage: \"useMessagePartImage\",\n useTextContentPart: \"useTextMessagePart\",\n\n // Primitive names\n ContentPartPrimitive: \"MessagePartPrimitive\",\n ContentPartPrimitiveText: \"MessagePartPrimitiveText\",\n ContentPartPrimitiveImage: \"MessagePartPrimitiveImage\",\n ContentPartPrimitiveInProgress: \"MessagePartPrimitiveInProgress\",\n};\n\nconst migrateContentPartToMessagePart = createTransformer(\n ({ j, root, markAsChanged }) => {\n // 1. Update imports\n root.find(j.ImportDeclaration).forEach((path: any) => {\n const source = path.value.source.value;\n\n // Only process imports from @assistant-ui packages\n if (typeof source === \"string\" && source.startsWith(\"@assistant-ui/\")) {\n path.value.specifiers?.forEach((specifier: any) => {\n if (j.ImportSpecifier.check(specifier)) {\n const oldName = specifier.imported.name as string;\n if (typeRenamingMap[oldName]) {\n specifier.imported.name = typeRenamingMap[oldName];\n if (specifier.local && specifier.local.name === oldName) {\n specifier.local.name = typeRenamingMap[oldName];\n }\n markAsChanged();\n }\n }\n });\n }\n });\n\n // 2. Update MessagePrimitive.Content to MessagePrimitive.Parts\n root.find(j.MemberExpression).forEach((path: any) => {\n if (\n path.value.object &&\n path.value.object.name === \"MessagePrimitive\" &&\n path.value.property &&\n path.value.property.name === \"Content\"\n ) {\n path.value.property.name = \"Parts\";\n markAsChanged();\n }\n });\n\n // 3. Update JSX member expressions (e.g., MessagePrimitive.Content in JSX)\n root.find(j.JSXMemberExpression).forEach((path: any) => {\n if (\n path.value.object &&\n path.value.object.name === \"MessagePrimitive\" &&\n path.value.property &&\n path.value.property.name === \"Content\"\n ) {\n path.value.property.name = \"Parts\";\n markAsChanged();\n }\n });\n\n // 4. Update all identifiers for types, hooks, and primitives\n Object.entries(typeRenamingMap).forEach(([oldName, newName]) => {\n // Update type references\n root.find(j.TSTypeReference).forEach((path: any) => {\n if (path.value.typeName && path.value.typeName.name === oldName) {\n path.value.typeName.name = newName;\n markAsChanged();\n }\n });\n\n // Update identifier references\n root.find(j.Identifier).forEach((path: any) => {\n if (path.value.name === oldName) {\n // Skip if this is part of an import declaration (already handled above)\n if (j.ImportSpecifier.check(path.parent.value)) {\n return;\n }\n\n // Skip if this is a property key in an object\n if (\n j.Property.check(path.parent.value) &&\n path.parent.value.key === path.value\n ) {\n return;\n }\n\n // Skip if this is a property in a member expression\n if (\n j.MemberExpression.check(path.parent.value) &&\n path.parent.value.property === path.value\n ) {\n return;\n }\n\n path.value.name = newName;\n markAsChanged();\n }\n });\n\n // Update JSX element names\n root.find(j.JSXIdentifier).forEach((path: any) => {\n if (path.value.name === oldName) {\n path.value.name = newName;\n markAsChanged();\n }\n });\n });\n },\n);\n\nexport default migrateContentPartToMessagePart;\n"],"mappings":"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"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
//#region src/codemods/v0-12/assistant-api-to-aui.d.ts
|
|
1
2
|
declare const migrateAssistantApiToAui: (fileInfo: import("jscodeshift/src/core").FileInfo, api: import("jscodeshift/src/core").API, options: any) => string | null;
|
|
2
|
-
|
|
3
|
+
//#endregion
|
|
4
|
+
export { migrateAssistantApiToAui as default };
|
|
3
5
|
//# sourceMappingURL=assistant-api-to-aui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-api-to-aui.d.ts","
|
|
1
|
+
{"version":3,"file":"assistant-api-to-aui.d.ts","names":[],"sources":["../../../src/codemods/v0-12/assistant-api-to-aui.ts"],"mappings":";cAsFM,wBAAA,GAAwB,QAAA,iCAAA,QAAA,EAAA,GAAA,iCAAA,GAAA,EAAA,OAAA"}
|