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