@blocklet/pages-kit-agents 0.5.45 → 0.5.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.env.local.example +7 -0
  2. package/cli.ts +1 -1
  3. package/index.ts +0 -1
  4. package/lib/cjs/agents/content-reviwer.d.ts +1 -1
  5. package/lib/cjs/agents/multi-agent-page-writer.js +3 -10
  6. package/lib/cjs/agents/orchestrator/index.d.ts +115 -0
  7. package/lib/cjs/agents/orchestrator/index.js +264 -0
  8. package/lib/cjs/agents/orchestrator/orchestrator-prompts.d.ts +130 -0
  9. package/lib/cjs/agents/orchestrator/orchestrator-prompts.js +135 -0
  10. package/lib/cjs/agents/page-metadata-generator.d.ts +1 -1
  11. package/lib/cjs/agents/page-metadata-generator.js +4 -1
  12. package/lib/cjs/agents/page-structure-planner.d.ts +59 -22
  13. package/lib/cjs/agents/page-structure-planner.js +108 -78
  14. package/lib/cjs/agents/router-datacache-generator.d.ts +24 -0
  15. package/lib/cjs/agents/router-datacache-generator.js +78 -0
  16. package/lib/cjs/agents/section-content-generator.js +11 -8
  17. package/lib/cjs/agents/template-designer.d.ts +7 -6
  18. package/lib/cjs/agents/template-designer.js +22 -17
  19. package/lib/cjs/agents/template-generator.d.ts +55 -7
  20. package/lib/cjs/agents/template-generator.js +99 -89
  21. package/lib/cjs/index.d.ts +0 -1
  22. package/lib/cjs/index.js +0 -1
  23. package/lib/cjs/prompts/fs-memory-recorder.md +59 -0
  24. package/lib/cjs/prompts/fs-memory-retriever.md +30 -0
  25. package/lib/cjs/prompts/html-generator.md +91 -0
  26. package/lib/cjs/prompts/page-structure-planner-prompt.md +47 -0
  27. package/lib/cjs/prompts/page-structure-validator-prompt.md +78 -0
  28. package/lib/cjs/prompts/pages-kit-template-rule.md +491 -0
  29. package/lib/cjs/prompts/site-map-generator.md +126 -0
  30. package/lib/cjs/skill-agents/parse-component-list-agent.d.ts +100 -0
  31. package/lib/cjs/skill-agents/parse-component-list-agent.js +198 -0
  32. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  33. package/lib/cjs/utils/agent-utils.d.ts +4 -0
  34. package/lib/cjs/utils/agent-utils.js +106 -0
  35. package/lib/esm/agents/content-reviwer.d.ts +1 -1
  36. package/lib/esm/agents/multi-agent-page-writer.js +5 -12
  37. package/lib/esm/agents/orchestrator/index.d.ts +115 -0
  38. package/lib/esm/agents/orchestrator/index.js +243 -0
  39. package/lib/esm/agents/orchestrator/orchestrator-prompts.d.ts +130 -0
  40. package/lib/esm/agents/orchestrator/orchestrator-prompts.js +131 -0
  41. package/lib/esm/agents/page-metadata-generator.d.ts +1 -1
  42. package/lib/esm/agents/page-metadata-generator.js +4 -1
  43. package/lib/esm/agents/page-structure-planner.d.ts +59 -22
  44. package/lib/esm/agents/page-structure-planner.js +105 -78
  45. package/lib/esm/agents/router-datacache-generator.d.ts +24 -0
  46. package/lib/esm/agents/router-datacache-generator.js +72 -0
  47. package/lib/esm/agents/section-content-generator.js +11 -8
  48. package/lib/esm/agents/template-designer.d.ts +7 -6
  49. package/lib/esm/agents/template-designer.js +22 -14
  50. package/lib/esm/agents/template-generator.d.ts +55 -7
  51. package/lib/esm/agents/template-generator.js +98 -88
  52. package/lib/esm/index.d.ts +0 -1
  53. package/lib/esm/index.js +0 -1
  54. package/lib/esm/prompts/fs-memory-recorder.md +59 -0
  55. package/lib/esm/prompts/fs-memory-retriever.md +30 -0
  56. package/lib/esm/prompts/html-generator.md +91 -0
  57. package/lib/esm/prompts/page-structure-planner-prompt.md +47 -0
  58. package/lib/esm/prompts/page-structure-validator-prompt.md +78 -0
  59. package/lib/esm/prompts/pages-kit-template-rule.md +491 -0
  60. package/lib/esm/prompts/site-map-generator.md +126 -0
  61. package/lib/esm/skill-agents/parse-component-list-agent.d.ts +100 -0
  62. package/lib/esm/skill-agents/parse-component-list-agent.js +192 -0
  63. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  64. package/lib/esm/utils/agent-utils.d.ts +4 -0
  65. package/lib/esm/utils/agent-utils.js +105 -0
  66. package/lib/types/agents/content-reviwer.d.ts +1 -1
  67. package/lib/types/agents/orchestrator/index.d.ts +115 -0
  68. package/lib/types/agents/orchestrator/orchestrator-prompts.d.ts +130 -0
  69. package/lib/types/agents/page-metadata-generator.d.ts +1 -1
  70. package/lib/types/agents/page-structure-planner.d.ts +59 -22
  71. package/lib/types/agents/router-datacache-generator.d.ts +24 -0
  72. package/lib/types/agents/template-designer.d.ts +7 -6
  73. package/lib/types/agents/template-generator.d.ts +55 -7
  74. package/lib/types/index.d.ts +0 -1
  75. package/lib/types/skill-agents/parse-component-list-agent.d.ts +100 -0
  76. package/lib/types/tsconfig.tsbuildinfo +1 -1
  77. package/lib/types/utils/agent-utils.d.ts +4 -0
  78. package/package.json +10 -5
  79. package/workflow-cli.ts +61 -41
  80. package/lib/cjs/agents/page-structure-validator.d.ts +0 -30
  81. package/lib/cjs/agents/page-structure-validator.js +0 -124
  82. package/lib/esm/agents/page-structure-validator.d.ts +0 -30
  83. package/lib/esm/agents/page-structure-validator.js +0 -121
  84. package/lib/types/agents/page-structure-validator.d.ts +0 -30
@@ -0,0 +1,100 @@
1
+ import { FunctionAgent } from '@aigne/core';
2
+ import { z } from 'zod';
3
+ export declare const ComponentListSchema: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodString;
5
+ name: z.ZodString;
6
+ component: z.ZodString;
7
+ description: z.ZodString;
8
+ rawData: z.ZodOptional<z.ZodAny>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ name: string;
11
+ description: string;
12
+ id: string;
13
+ component: string;
14
+ rawData?: any;
15
+ }, {
16
+ name: string;
17
+ description: string;
18
+ id: string;
19
+ component: string;
20
+ rawData?: any;
21
+ }>, "many">;
22
+ export declare const ComponentListOutputSchema: z.ZodObject<{
23
+ data: z.ZodArray<z.ZodObject<{
24
+ id: z.ZodString;
25
+ name: z.ZodString;
26
+ component: z.ZodString;
27
+ description: z.ZodString;
28
+ rawData: z.ZodOptional<z.ZodAny>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ name: string;
31
+ description: string;
32
+ id: string;
33
+ component: string;
34
+ rawData?: any;
35
+ }, {
36
+ name: string;
37
+ description: string;
38
+ id: string;
39
+ component: string;
40
+ rawData?: any;
41
+ }>, "many">;
42
+ summary: z.ZodObject<{
43
+ total: z.ZodNumber;
44
+ basicComponents: z.ZodRecord<z.ZodString, z.ZodString>;
45
+ customComponents: z.ZodRecord<z.ZodString, z.ZodString>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ total: number;
48
+ basicComponents: Record<string, string>;
49
+ customComponents: Record<string, string>;
50
+ }, {
51
+ total: number;
52
+ basicComponents: Record<string, string>;
53
+ customComponents: Record<string, string>;
54
+ }>;
55
+ }, "strip", z.ZodTypeAny, {
56
+ data: {
57
+ name: string;
58
+ description: string;
59
+ id: string;
60
+ component: string;
61
+ rawData?: any;
62
+ }[];
63
+ summary: {
64
+ total: number;
65
+ basicComponents: Record<string, string>;
66
+ customComponents: Record<string, string>;
67
+ };
68
+ }, {
69
+ data: {
70
+ name: string;
71
+ description: string;
72
+ id: string;
73
+ component: string;
74
+ rawData?: any;
75
+ }[];
76
+ summary: {
77
+ total: number;
78
+ basicComponents: Record<string, string>;
79
+ customComponents: Record<string, string>;
80
+ };
81
+ }>;
82
+ export declare const parseComponentListAgent: FunctionAgent<{
83
+ componentListDir?: string | undefined;
84
+ }, {
85
+ componentListYaml: string;
86
+ componentList: {
87
+ data: {
88
+ name: string;
89
+ description: string;
90
+ id: string;
91
+ component: string;
92
+ rawData?: any;
93
+ }[];
94
+ summary: {
95
+ total: number;
96
+ basicComponents: Record<string, string>;
97
+ customComponents: Record<string, string>;
98
+ };
99
+ };
100
+ }>;
@@ -0,0 +1,192 @@
1
+ import { FunctionAgent } from '@aigne/core';
2
+ import fs from 'fs/promises';
3
+ import yaml from 'js-yaml';
4
+ import path from 'path';
5
+ import { z } from 'zod';
6
+ // Constants
7
+ const MOCK_COMPONENTS_DIR = path.join(__dirname, '../mock-data/components');
8
+ const BASIC_COMPONENT_LIST = [
9
+ {
10
+ id: 'section',
11
+ name: 'Section',
12
+ component: 'section',
13
+ description: '基础内容区块,支持标题、描述、图片和徽章展示,常用于Hero区域或产品介绍',
14
+ },
15
+ {
16
+ id: 'section-card-list',
17
+ name: 'Section Card List',
18
+ component: 'section-card-list',
19
+ description: '卡片列表组件,用于展示多个并列的信息卡片,适合特性介绍或服务展示',
20
+ },
21
+ {
22
+ id: 'toc',
23
+ name: 'Toc',
24
+ component: 'toc',
25
+ description: '目录组件,自动生成页面内容导航,支持锚点跳转',
26
+ },
27
+ {
28
+ id: 'iframe',
29
+ name: 'Embed',
30
+ component: 'iframe',
31
+ description: '嵌入组件,用于集成外部内容如视频、地图、第三方服务等',
32
+ },
33
+ {
34
+ id: 'layout-block',
35
+ name: 'Section Layout',
36
+ component: 'layout-block',
37
+ description: '布局容器组件,提供灵活的页面结构化布局,可嵌套其他组件',
38
+ },
39
+ ];
40
+ // Zod schemas for validation
41
+ const ComponentListItemSchema = z.object({
42
+ id: z.string(),
43
+ name: z.string(),
44
+ component: z.string(),
45
+ description: z.string(),
46
+ rawData: z.any().describe('Raw data from the component file').optional(),
47
+ });
48
+ export const ComponentListSchema = z.array(ComponentListItemSchema);
49
+ export const ComponentListOutputSchema = z
50
+ .object({
51
+ data: ComponentListSchema,
52
+ summary: z.object({
53
+ total: z.number(),
54
+ basicComponents: z.record(z.string(), z.string()),
55
+ customComponents: z.record(z.string(), z.string()),
56
+ }),
57
+ })
58
+ .describe('Component list in json format');
59
+ /**
60
+ * Parse component data - customize this function for data processing
61
+ * @param rawData Raw component data from file
62
+ * @param filename Original filename
63
+ * @returns Processed component list item
64
+ */
65
+ function processComponentData(rawData, filename) {
66
+ // Extract ID from filename (format: ComponentName.ID.yml/json)
67
+ const parts = filename.split('.');
68
+ const id = parts.length >= 2 ? parts[parts.length - 2] : parts[0];
69
+ const name = parts[0];
70
+ // Default processing - customize as needed
71
+ const processed = {
72
+ id: id || 'unknown-id',
73
+ name: rawData.name || name,
74
+ component: rawData.component || 'custom-component',
75
+ description: rawData.description || `${name} component`,
76
+ rawData,
77
+ };
78
+ // Add any custom processing logic here
79
+ return processed;
80
+ }
81
+ /**
82
+ * Read and parse component files from directory
83
+ * @param directory Target directory path
84
+ * @returns Array of parsed component files
85
+ */
86
+ async function readComponentFiles(directory) {
87
+ try {
88
+ const files = await fs.readdir(directory);
89
+ const componentFiles = [];
90
+ for (const filename of files) {
91
+ const ext = path.extname(filename).toLowerCase();
92
+ // Only process .yml, .yaml, and .json files
93
+ if (!['.yml', '.yaml', '.json'].includes(ext)) {
94
+ // eslint-disable-next-line no-continue
95
+ continue;
96
+ }
97
+ const filePath = path.join(directory, filename);
98
+ const fileContent = await fs.readFile(filePath, 'utf-8');
99
+ let content;
100
+ // Parse based on file extension
101
+ if (ext === '.json') {
102
+ content = JSON.parse(fileContent);
103
+ }
104
+ else {
105
+ content = yaml.load(fileContent);
106
+ }
107
+ // Extract ID from filename
108
+ const fileParts = filename.split('.');
109
+ const id = fileParts.length >= 2 ? fileParts[fileParts.length - 2] : fileParts[0];
110
+ componentFiles.push({
111
+ filename,
112
+ content,
113
+ id: id || 'unknown-id',
114
+ });
115
+ }
116
+ return componentFiles;
117
+ }
118
+ catch (error) {
119
+ console.error('Error reading component files:', error);
120
+ throw error;
121
+ }
122
+ }
123
+ /**
124
+ * Generate component list from parsed files
125
+ * @param componentFiles Array of component files
126
+ * @returns Generated component list
127
+ */
128
+ function generateComponentList(componentFiles) {
129
+ const components = [
130
+ // basic components
131
+ ...BASIC_COMPONENT_LIST,
132
+ // custom components
133
+ ...componentFiles.map((file) => processComponentData(file.content, file.filename)),
134
+ ];
135
+ // Categorize components
136
+ const basicComponentsSummary = {};
137
+ const customComponentsSummary = {};
138
+ components.forEach((comp) => {
139
+ if (comp.component === 'custom-component') {
140
+ customComponentsSummary[comp.name] = comp.description;
141
+ }
142
+ else {
143
+ basicComponentsSummary[comp.name] = comp.description;
144
+ }
145
+ });
146
+ return {
147
+ data: components,
148
+ summary: {
149
+ total: components.length,
150
+ basicComponents: basicComponentsSummary,
151
+ customComponents: customComponentsSummary,
152
+ },
153
+ };
154
+ }
155
+ export const parseComponentListAgent = FunctionAgent.from({
156
+ name: 'parse_component_list',
157
+ description: 'Parse component list from YAML/JSON files in specified directory and generate component list structure',
158
+ inputSchema: z.object({
159
+ componentListDir: z.string().optional().describe('Custom directory path to read components from'),
160
+ }),
161
+ outputSchema: z.object({
162
+ componentListYaml: z.string().describe('Component list in YAML format, without raw data'),
163
+ componentList: ComponentListOutputSchema,
164
+ }),
165
+ async process({ componentListDir }) {
166
+ const targetDir = componentListDir || MOCK_COMPONENTS_DIR;
167
+ try {
168
+ // Read component files
169
+ const componentFiles = await readComponentFiles(targetDir);
170
+ // Generate component list
171
+ const componentListData = generateComponentList(componentFiles);
172
+ const componentListDataWithoutRawData = componentListData.data.map((item) => {
173
+ const { rawData, ...rest } = item;
174
+ return rest;
175
+ });
176
+ // Convert to YAML
177
+ const componentListYaml = yaml.dump(componentListDataWithoutRawData, {
178
+ indent: 2,
179
+ lineWidth: -1,
180
+ noRefs: true,
181
+ });
182
+ return {
183
+ componentListYaml,
184
+ componentList: componentListData,
185
+ };
186
+ }
187
+ catch (error) {
188
+ console.error('Error parsing component list:', error);
189
+ throw error;
190
+ }
191
+ },
192
+ });