superun-ai-cli 0.1.19 → 0.1.22
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/README.md +16 -1
- package/dist/api/agent-query-api.d.ts +7 -0
- package/dist/api/agent-query-api.js +44 -0
- package/dist/api/agent-query-api.js.map +1 -1
- package/dist/commands/chat/publish.js +15 -2
- package/dist/commands/chat/publish.js.map +1 -1
- package/dist/commands/chat/style.js +1 -1
- package/dist/commands/chat/style.js.map +1 -1
- package/dist/contracts/cli-output.d.ts +22 -0
- package/dist/contracts/node-wire.d.ts +5 -0
- package/dist/contracts/node-wire.js +1 -0
- package/dist/contracts/node-wire.js.map +1 -1
- package/dist/conversation/next-actions.js +4 -2
- package/dist/conversation/next-actions.js.map +1 -1
- package/dist/conversation/project-routing.d.ts +15 -0
- package/dist/conversation/project-routing.js +85 -0
- package/dist/conversation/project-routing.js.map +1 -0
- package/dist/conversation/route-parser.d.ts +105 -0
- package/dist/conversation/route-parser.js +783 -0
- package/dist/conversation/route-parser.js.map +1 -0
- package/dist/conversation/style-generation.d.ts +2 -2
- package/dist/conversation/style-generation.js +3 -3
- package/dist/conversation/style-generation.js.map +1 -1
- package/dist/conversation/style-guidance.js +1 -1
- package/dist/conversation/style-guidance.js.map +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +29 -14
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 路由解析工具
|
|
3
|
+
* @author xiuyu.yi
|
|
4
|
+
* 移植自 Glow client/src/pages/project/utils/route-parser.ts,保持同源分组和排序规则。
|
|
5
|
+
*
|
|
6
|
+
* 从 App.tsx / routes.tsx 内容中解析路由信息,支持:
|
|
7
|
+
* - 多端路由分端:JSX 取 handle={{ side }}(结构化优先)/ `// @side:` 注释兜底;data-mode 取 RouteObject 的 handle.side
|
|
8
|
+
* - JSX <Route>(App.tsx)与 RouteObject[](routes.tsx,data-mode/SSR)两种路由源
|
|
9
|
+
* - 嵌套路由 / 扁平路由 / 单组件应用
|
|
10
|
+
*/
|
|
11
|
+
export type Route = {
|
|
12
|
+
path: string;
|
|
13
|
+
name: string;
|
|
14
|
+
codePath?: string;
|
|
15
|
+
side?: string;
|
|
16
|
+
};
|
|
17
|
+
export type RouteGroup = {
|
|
18
|
+
side: string;
|
|
19
|
+
label: string;
|
|
20
|
+
basePath: string;
|
|
21
|
+
routes: Route[];
|
|
22
|
+
};
|
|
23
|
+
/** 路由配置文件查找顺序:独立 routes.tsx 优先于 App.tsx */
|
|
24
|
+
export declare const ROUTE_CONFIG_FILENAMES: readonly ["src/routes.tsx", "src/App.tsx"];
|
|
25
|
+
export type RouteConfigAttachmentCandidate = {
|
|
26
|
+
name: string;
|
|
27
|
+
content?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function matchesRouteConfigFilename(name: string, filename: (typeof ROUTE_CONFIG_FILENAMES)[number]): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 从 attachments 中查找带 content 的路由配置文件(routes.tsx 优先,其次 App.tsx)
|
|
32
|
+
* 原实现作者:lidewen
|
|
33
|
+
*/
|
|
34
|
+
export declare function findRouteConfigAttachment<T extends RouteConfigAttachmentCandidate>(attachments: readonly T[]): T | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* 规范化 import 路径
|
|
37
|
+
* 将 @/ 或 ./ 转换为 src/,并添加文件扩展名
|
|
38
|
+
*/
|
|
39
|
+
export declare const normalizeImportPath: (importPath: string) => string;
|
|
40
|
+
/**
|
|
41
|
+
* 判断路由是否为动态路由(包含 :param 动态参数或 * 通配符)
|
|
42
|
+
* 例如:/users/:id -> true, /products/:category/:slug -> true, /about -> false
|
|
43
|
+
*/
|
|
44
|
+
export declare const isDynamicRoute: (path: string) => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 将组件名转换为友好的显示名称
|
|
47
|
+
* 例如:UserProfile -> User Profile
|
|
48
|
+
*/
|
|
49
|
+
export declare const toFriendlyName: (componentName: string) => string;
|
|
50
|
+
/**
|
|
51
|
+
* 解析 import 语句,建立组件名到文件路径的映射
|
|
52
|
+
*/
|
|
53
|
+
export declare const parseImportMap: (content: string) => Record<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* 从 `const xxxRoutes = ( ... )` 的路由块推断该端 basePath(对应最外层 Route 的 path)。
|
|
56
|
+
* 只在「第一个 `<Route` 到第二个 `<Route` 之前」的片段里找 path,避免把子路由的 path 误当成父级 base。
|
|
57
|
+
* 若父级为无 path 的 layout(仅 element),则视为挂载在根 `/`。
|
|
58
|
+
* 原实现作者:lidewen
|
|
59
|
+
*/
|
|
60
|
+
export declare function inferGroupBasePathFromRouteBlock(routeBlock: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* 从路由块抽出顶层 <Route> 的 handle={{ side: "X" }} 的 X。
|
|
63
|
+
* 这是结构化的分端标记,比 `// @side:` 注释更抗格式化/重生成;约定里每端顶层 <Route> 带 handle、
|
|
64
|
+
* 子路由继承不重复,故取首个匹配即该组的 side。读不到(无 handle)→ undefined,由调用方回退注释/变量名。
|
|
65
|
+
*/
|
|
66
|
+
export declare function extractHandleSideFromRouteBlock(routeBlock: string): string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* 从嵌套路由块中解析路由
|
|
69
|
+
*/
|
|
70
|
+
export declare const parseNestedRoutes: (routeBlock: string, parentPath: string, side: string, importMap: Record<string, string>) => Route[];
|
|
71
|
+
/**
|
|
72
|
+
* 从变量名推断 side 名称
|
|
73
|
+
* 例如:adminRoutes -> Admin, userRoutes -> User, workspaceGroup -> Workspace
|
|
74
|
+
*/
|
|
75
|
+
export declare const inferSideFromVarName: (varName: string) => string;
|
|
76
|
+
/**
|
|
77
|
+
* 解析扁平路由(兼容旧格式,无 @side 注释)
|
|
78
|
+
*/
|
|
79
|
+
export declare const parseFlatRoutes: (content: string, importMap: Record<string, string>) => Route[];
|
|
80
|
+
/**
|
|
81
|
+
* 从 App.tsx 内容中解析路由分组
|
|
82
|
+
*
|
|
83
|
+
* 解析优先级:
|
|
84
|
+
* 1. 带 @side 注释的路由组
|
|
85
|
+
* 2. 缺少注释的 xxxRoutes 变量
|
|
86
|
+
* 3. 扁平路由
|
|
87
|
+
* 4. 默认路由
|
|
88
|
+
*/
|
|
89
|
+
export declare const parseRouteGroupsFromAppTsx: (content: string, onFallback?: () => void) => RouteGroup[];
|
|
90
|
+
/**
|
|
91
|
+
* 从 routes.tsx 的 RouteObject[] 解析路由分组(data-mode / SSR 项目)。
|
|
92
|
+
* 解析不出(非 RouteObject、无 routes 数组、异常)→ 返回 [],交回上层兜底。
|
|
93
|
+
*/
|
|
94
|
+
export declare const parseRouteGroupsFromRouteObjects: (content: string) => RouteGroup[];
|
|
95
|
+
/**
|
|
96
|
+
* 路由分组统一入口(自动分发):
|
|
97
|
+
* - 含 JSX `<Route>` → 走 parseRouteGroupsFromAppTsx(CSR / 原型项目)
|
|
98
|
+
* - 否则尝试 RouteObject[] 解析(data-mode / SSR 的 routes.tsx)
|
|
99
|
+
* - 都解析不出 → 回到 parseRouteGroupsFromAppTsx 的兜底(默认单条 /)
|
|
100
|
+
*/
|
|
101
|
+
export declare const parseRouteGroups: (content: string, onFallback?: () => void) => RouteGroup[];
|
|
102
|
+
/**
|
|
103
|
+
* 创建默认路由分组
|
|
104
|
+
*/
|
|
105
|
+
export declare const createDefaultRouteGroups: () => RouteGroup[];
|