@blocklet/pages-kit-agents 0.5.47 → 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 +8 -3
- 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
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.designerAgent = void 0;
|
|
7
|
-
|
|
4
|
+
// import { DefaultMemory } from '@aigne/agent-library/default-memory/index.js';
|
|
8
5
|
const core_1 = require("@aigne/core");
|
|
9
|
-
|
|
10
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
6
|
+
// import assert from 'node:assert';
|
|
12
7
|
const zod_1 = require("zod");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
// const { OPENAI_API_KEY } = process.env;
|
|
10
|
+
// assert(OPENAI_API_KEY, 'Please set the OPENAI_API_KEY environment variable');
|
|
11
|
+
// const memory = new DefaultMemory({
|
|
12
|
+
// storage: {
|
|
13
|
+
// url: 'file:./dbs/memory.db', // Path to store memory data, such as 'file:./memory.db'
|
|
14
|
+
// },
|
|
15
|
+
// });
|
|
21
16
|
const agentInstructions = `
|
|
22
17
|
你是一个专业的页面设计师,名叫小设。你的任务是根据整理好的用户需求,设计一个页面结构。
|
|
23
18
|
|
|
@@ -33,7 +28,7 @@ const agentInstructions = `
|
|
|
33
28
|
|
|
34
29
|
支持使用的组件列表:
|
|
35
30
|
<component-list>
|
|
36
|
-
|
|
31
|
+
{{componentListYaml}}
|
|
37
32
|
</component-list>
|
|
38
33
|
|
|
39
34
|
整理好的用户需求:
|
|
@@ -49,19 +44,29 @@ ${componentList}
|
|
|
49
44
|
* 1. AI 根据拿到的 collectorResult 和 componentList,生成一个页面设计模板,需要用 ASCII 图画出来,给到用户确认
|
|
50
45
|
* 2. 用户确认后,AI 保存页面设计模板,并返回页面设计模板
|
|
51
46
|
*/
|
|
47
|
+
const memory = (0, utils_1.getMemory)({});
|
|
52
48
|
exports.designerAgent = core_1.AIAgent.from({
|
|
53
49
|
name: 'designer',
|
|
54
50
|
description: '设计页面结构,并且给到用户确认',
|
|
55
51
|
inputSchema: zod_1.z.object({
|
|
56
52
|
collectResult: zod_1.z.string().describe('整理好的用户需求'),
|
|
53
|
+
componentListYaml: zod_1.z.string().describe('支持使用的组件列表 YAML 结构'),
|
|
57
54
|
}),
|
|
58
55
|
outputSchema: zod_1.z.object({
|
|
59
56
|
ascii: zod_1.z.string().describe('ASCII 图'),
|
|
60
57
|
$message: zod_1.z.string().describe('给到用户的信息,用于用户确认,不需要包含 ASCII 图'),
|
|
61
|
-
filteredComponentList: zod_1.z
|
|
58
|
+
filteredComponentList: zod_1.z
|
|
59
|
+
.array(zod_1.z.object({
|
|
60
|
+
id: zod_1.z.string(),
|
|
61
|
+
name: zod_1.z.string(),
|
|
62
|
+
component: zod_1.z.string(),
|
|
63
|
+
description: zod_1.z.string(),
|
|
64
|
+
}))
|
|
65
|
+
.describe('过滤后的组件列表,只包含页面中需要的组件'),
|
|
62
66
|
}),
|
|
63
67
|
memory,
|
|
64
68
|
instructions: `
|
|
65
69
|
${agentInstructions}
|
|
66
70
|
`,
|
|
71
|
+
includeInputInOutput: true,
|
|
67
72
|
});
|
|
@@ -1,18 +1,66 @@
|
|
|
1
1
|
import { FunctionAgent } from '@aigne/core';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { ReflectionAgent } from '../workflow-agents/reflection-agent.js';
|
|
4
|
+
export declare const generatorParamsSchema: z.ZodObject<{
|
|
5
|
+
ascii: z.ZodString;
|
|
6
|
+
collectResult: z.ZodString;
|
|
7
|
+
filteredComponentList: z.ZodArray<z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
component: z.ZodString;
|
|
11
|
+
description: z.ZodString;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
id: string;
|
|
16
|
+
component: string;
|
|
17
|
+
}, {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
id: string;
|
|
21
|
+
component: string;
|
|
22
|
+
}>, "many">;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
ascii: string;
|
|
25
|
+
collectResult: string;
|
|
26
|
+
filteredComponentList: {
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
id: string;
|
|
30
|
+
component: string;
|
|
31
|
+
}[];
|
|
32
|
+
}, {
|
|
33
|
+
ascii: string;
|
|
34
|
+
collectResult: string;
|
|
35
|
+
filteredComponentList: {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
id: string;
|
|
39
|
+
component: string;
|
|
40
|
+
}[];
|
|
41
|
+
}>;
|
|
3
42
|
export declare const generatorAgentWithReflection: ReflectionAgent<{
|
|
4
43
|
ascii: string;
|
|
5
44
|
collectResult: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
45
|
+
filteredComponentList: {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
id: string;
|
|
49
|
+
component: string;
|
|
50
|
+
}[];
|
|
9
51
|
}, {
|
|
10
52
|
isApproved: boolean;
|
|
11
|
-
feedback:
|
|
53
|
+
feedback: {
|
|
54
|
+
description: string;
|
|
55
|
+
line: number;
|
|
56
|
+
column: number;
|
|
57
|
+
keyword: string;
|
|
58
|
+
rule: string;
|
|
59
|
+
isRequired: boolean;
|
|
60
|
+
}[];
|
|
12
61
|
}>;
|
|
13
|
-
export declare const
|
|
14
|
-
|
|
15
|
-
yaml: string;
|
|
62
|
+
export declare const saveTemplateYamlAgent: FunctionAgent<{
|
|
63
|
+
templateYaml: string;
|
|
16
64
|
}, {
|
|
17
65
|
$message: string;
|
|
18
66
|
} & import("@aigne/core").Message>;
|
|
@@ -3,25 +3,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.saveTemplateYamlAgent = exports.generatorAgentWithReflection = exports.generatorParamsSchema = void 0;
|
|
7
|
+
// import { DefaultMemory } from '@aigne/agent-library/default-memory/index.js';
|
|
8
8
|
const core_1 = require("@aigne/core");
|
|
9
|
-
|
|
9
|
+
// import assert from 'node:assert';
|
|
10
10
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
12
12
|
const zod_1 = require("zod");
|
|
13
|
+
const agent_utils_js_1 = require("../utils/agent-utils.js");
|
|
13
14
|
const reflection_agent_js_1 = require("../workflow-agents/reflection-agent.js");
|
|
14
|
-
const { OPENAI_API_KEY } = process.env;
|
|
15
|
-
|
|
16
|
-
const memory = new
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
const
|
|
22
|
-
const
|
|
15
|
+
// const { OPENAI_API_KEY } = process.env;
|
|
16
|
+
// assert(OPENAI_API_KEY, 'Please set the OPENAI_API_KEY environment variable');
|
|
17
|
+
// const memory = new DefaultMemory({
|
|
18
|
+
// storage: {
|
|
19
|
+
// url: 'file:./dbs/memory.db', // Path to store memory data, such as 'file:./memory.db'
|
|
20
|
+
// },
|
|
21
|
+
// });
|
|
22
|
+
const pagesKitTemplateRule = node_fs_1.default.readFileSync(node_path_1.default.join(__dirname, '../prompts/pages-kit-template-rule.md'), 'utf-8');
|
|
23
|
+
const contextRule = `
|
|
24
|
+
## 技术规范参考
|
|
25
|
+
<pages-kit-template-rule>
|
|
26
|
+
${pagesKitTemplateRule}
|
|
27
|
+
</pages-kit-template-rule>
|
|
28
|
+
|
|
29
|
+
## 全部组件列表
|
|
30
|
+
<component-list>
|
|
31
|
+
{{componentListYaml}}
|
|
32
|
+
</component-list>
|
|
33
|
+
|
|
34
|
+
## 当前任务输入
|
|
35
|
+
设计师页面模板:
|
|
36
|
+
<ascii>
|
|
37
|
+
{{ascii}}
|
|
38
|
+
</ascii>
|
|
39
|
+
|
|
40
|
+
本次可使用的组件列表
|
|
41
|
+
<filtered-component-list>
|
|
42
|
+
{{filteredComponentList}}
|
|
43
|
+
</filtered-component-list>
|
|
44
|
+
|
|
45
|
+
<#if templateYaml>
|
|
46
|
+
## 上一次生成的模板 YAML 结构
|
|
47
|
+
<template-yaml>
|
|
48
|
+
{{templateYaml}}
|
|
49
|
+
</template-yaml>
|
|
50
|
+
</#if>
|
|
51
|
+
|
|
52
|
+
`;
|
|
23
53
|
const generatorAgentInstructions = `
|
|
24
54
|
你是专业的 Pages Kit 模板工程师小猿。你的任务是根据用户需求和设计师的页面设计模板,生成完全符合 Pages Kit 框架规范的 YAML 结构。
|
|
55
|
+
当前时间:${new Date().toISOString()}
|
|
25
56
|
|
|
26
57
|
## 核心职责
|
|
27
58
|
基于提供的用户需求、设计师ASCII图和组件列表,生成可直接使用的 Pages Kit YAML 模板。
|
|
@@ -39,48 +70,17 @@ const generatorAgentInstructions = `
|
|
|
39
70
|
- 确保所有组件都来自提供的过滤组件列表
|
|
40
71
|
- 必须返回所有输入字段以保持数据流的完整性
|
|
41
72
|
|
|
42
|
-
|
|
43
|
-
<pages-kit-template-rule>
|
|
44
|
-
${pagesKitTemplateRule}
|
|
45
|
-
</pages-kit-template-rule>
|
|
46
|
-
|
|
47
|
-
## 全部可用组件
|
|
48
|
-
<component-list>
|
|
49
|
-
${componentList}
|
|
50
|
-
</component-list>
|
|
51
|
-
|
|
52
|
-
## 当前任务输入
|
|
53
|
-
用户需求:
|
|
54
|
-
<collect-result>
|
|
55
|
-
{{collectResult}}
|
|
56
|
-
</collect-result>
|
|
57
|
-
|
|
58
|
-
设计师页面模板:
|
|
59
|
-
<ascii>
|
|
60
|
-
{{ascii}}
|
|
61
|
-
</ascii>
|
|
62
|
-
|
|
63
|
-
本次可使用的组件(已过滤):
|
|
64
|
-
<filtered-component-list>
|
|
65
|
-
{{filteredComponentList}}
|
|
66
|
-
</filtered-component-list>
|
|
73
|
+
${contextRule}
|
|
67
74
|
|
|
68
75
|
<#if feedback>
|
|
69
76
|
## 验证反馈
|
|
70
|
-
|
|
77
|
+
上一次生成的模板 YAML 结构存在以下问题,请根据反馈对模板 YAML 结构进行修正:
|
|
71
78
|
<feedback>
|
|
72
79
|
{{feedback}}
|
|
73
80
|
</feedback>
|
|
74
81
|
</#if>
|
|
75
82
|
|
|
76
|
-
|
|
77
|
-
## 上一次生成的YAML结构
|
|
78
|
-
<yaml>
|
|
79
|
-
{{yaml}}
|
|
80
|
-
</yaml>
|
|
81
|
-
</#if>
|
|
82
|
-
|
|
83
|
-
请严格按照上述要求生成YAML结构,并确保返回所有必需的字段。`;
|
|
83
|
+
请严格按照上述要求生成模板 YAML 结构,并确保返回所有必需的字段。`;
|
|
84
84
|
const validatorAgentInstructions = `
|
|
85
85
|
你是专业的 Pages Kit 模板验证专家小验。你的任务是严格验证生成的 YAML 结构是否完全符合 Pages Kit 框架规范。
|
|
86
86
|
|
|
@@ -88,31 +88,50 @@ const validatorAgentInstructions = `
|
|
|
88
88
|
对生成的 YAML 模板进行全面技术验证,确保其在 Pages Kit 框架中能够正确运行。
|
|
89
89
|
|
|
90
90
|
## 验证检查清单
|
|
91
|
+
请严格按照以下要求进行验证,如果发现不符合要求,请进行反馈说明:
|
|
91
92
|
1. **结构规范性**: 严格检查是否完全符合 Pages Kit 框架的 YAML Schema 结构
|
|
92
93
|
2. **语法正确性**: 验证 YAML 语法格式是否正确,缩进、字段名等是否准确
|
|
93
|
-
3. **ID唯一性**:
|
|
94
|
+
3. **ID 唯一性**: 对于在 sections 结构中的每个 section,其 id 属性值必须唯一且为 16 位随机字符串(字母数字混合,非语义化)。
|
|
95
|
+
- 注意:layout-block 中 config.gridSettings 内容,通常会包含这些 id 用于描述布局,并非违背 ID 唯一性,请忽略
|
|
94
96
|
4. **组件合法性**: 确认所有使用的组件都在允许的组件列表中
|
|
95
97
|
5. **属性完整性**: 检查必需属性是否全部提供,可选属性是否合理
|
|
96
98
|
6. **嵌套层级**: 验证嵌套结构深度和层级关系是否正确
|
|
97
99
|
7. **数据类型**: 确认各字段的数据类型符合规范要求
|
|
98
100
|
|
|
99
|
-
## 技术规范依据
|
|
100
|
-
<pages-kit-template-rule>
|
|
101
|
-
${pagesKitTemplateRule}
|
|
102
|
-
</pages-kit-template-rule>
|
|
103
|
-
|
|
104
|
-
## 验证输入
|
|
105
|
-
用户需求:{{collectResult}}
|
|
106
|
-
设计师ASCII图:{{ascii}}
|
|
107
|
-
可用组件列表:{{filteredComponentList}}
|
|
108
|
-
生成的YAML:{{yaml}}
|
|
109
|
-
|
|
110
101
|
## 验证原则
|
|
111
102
|
- 零容忍态度对待规范违规
|
|
112
103
|
- 优先保证模板的可执行性和稳定性
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
|
|
104
|
+
- 推荐或者可选的内容并非强制使用,需要根据实际情况判断,如果有更好的实现方式,请进行反馈说明
|
|
105
|
+
- 发现问题时提供清晰的改进建议,需要定位到第几行第几列、问题描述、违反的规范,方便后续修改
|
|
106
|
+
|
|
107
|
+
${contextRule}
|
|
108
|
+
|
|
109
|
+
请对提供的模板 YAML 结构进行全面验证。`;
|
|
110
|
+
const feedbackSchema = zod_1.z
|
|
111
|
+
.array(zod_1.z.object({
|
|
112
|
+
line: zod_1.z.number().describe('行号'),
|
|
113
|
+
column: zod_1.z.number().describe('列号'),
|
|
114
|
+
keyword: zod_1.z.string().describe('关键字'),
|
|
115
|
+
description: zod_1.z.string().describe('问题描述,期望是什么样的,现在是什么样的,为什么不符合规范'),
|
|
116
|
+
rule: zod_1.z.string().describe('违反的规范'),
|
|
117
|
+
// 是否必须修改
|
|
118
|
+
isRequired: zod_1.z.boolean().describe('是否必须修改'),
|
|
119
|
+
}))
|
|
120
|
+
.describe('验证器整理的详细反馈');
|
|
121
|
+
const templateYamlSchema = zod_1.z.string().describe('模板 Yaml 结构');
|
|
122
|
+
exports.generatorParamsSchema = zod_1.z.object({
|
|
123
|
+
ascii: zod_1.z.string().describe('ASCII 图'),
|
|
124
|
+
collectResult: zod_1.z.string().describe('整理好的用户需求'),
|
|
125
|
+
filteredComponentList: zod_1.z
|
|
126
|
+
.array(zod_1.z.object({
|
|
127
|
+
id: zod_1.z.string(),
|
|
128
|
+
name: zod_1.z.string(),
|
|
129
|
+
component: zod_1.z.string(),
|
|
130
|
+
description: zod_1.z.string(),
|
|
131
|
+
}))
|
|
132
|
+
.describe('过滤后的组件列表,只包含页面设计需要的组件'),
|
|
133
|
+
});
|
|
134
|
+
const memory = (0, agent_utils_js_1.getMemory)({ autoUpdate: false });
|
|
116
135
|
/**
|
|
117
136
|
* 用于实现页面结构的 workflow
|
|
118
137
|
* 1. AI 根据拿到的 ASCII 图,整理好的用户需求,支持使用的组件列表,生成一个 Yaml 结构,给到验证器验证
|
|
@@ -123,44 +142,33 @@ const generatorAgent = core_1.AIAgent.from({
|
|
|
123
142
|
name: 'generator',
|
|
124
143
|
description: '实现页面结构,并且给到用户确认',
|
|
125
144
|
inputSchema: zod_1.z.object({
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
$message: zod_1.z.string(),
|
|
130
|
-
feedback: zod_1.z.string().nullish().describe('Feedback from the reviewer'),
|
|
145
|
+
...exports.generatorParamsSchema.shape,
|
|
146
|
+
templateYaml: templateYamlSchema.optional().default(''),
|
|
147
|
+
feedback: feedbackSchema.optional().default([]),
|
|
131
148
|
}),
|
|
132
149
|
outputSchema: zod_1.z.object({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
filteredComponentList: zod_1.z.array(zod_1.z.string()).describe('过滤后的组件列表,只包含页面设计需要的组件'),
|
|
136
|
-
$message: zod_1.z.string().describe('给到用户的信息,用于用户确认'),
|
|
137
|
-
yaml: zod_1.z.string().describe('Yaml 结构'),
|
|
138
|
-
feedback: zod_1.z.string().nullish().describe('Feedback from the reviewer'),
|
|
150
|
+
...exports.generatorParamsSchema.shape,
|
|
151
|
+
templateYaml: templateYamlSchema,
|
|
139
152
|
}),
|
|
140
153
|
memory,
|
|
141
154
|
instructions: `
|
|
142
155
|
${generatorAgentInstructions}
|
|
143
156
|
`,
|
|
157
|
+
includeInputInOutput: true,
|
|
144
158
|
});
|
|
145
159
|
const validatorAgent = core_1.AIAgent.from({
|
|
146
160
|
name: 'validator',
|
|
147
161
|
description: '验证 Yaml 结构符合 Pages Kit 框架的 Yaml Schema 结构',
|
|
148
|
-
inputSchema:
|
|
149
|
-
ascii: zod_1.z.string().describe('ASCII 图'),
|
|
150
|
-
collectResult: zod_1.z.string().describe('整理好的用户需求'),
|
|
151
|
-
filteredComponentList: zod_1.z.array(zod_1.z.string()).describe('过滤后的组件列表,只包含页面设计需要的组件'),
|
|
152
|
-
$message: zod_1.z.string(),
|
|
153
|
-
yaml: zod_1.z.string().describe('Yaml 结构'),
|
|
154
|
-
feedback: zod_1.z.string().nullish().describe('Feedback from the reviewer'),
|
|
155
|
-
}),
|
|
162
|
+
inputSchema: exports.generatorParamsSchema,
|
|
156
163
|
memory,
|
|
157
164
|
outputSchema: zod_1.z.object({
|
|
158
|
-
isApproved: zod_1.z.boolean().describe('
|
|
159
|
-
feedback:
|
|
165
|
+
isApproved: zod_1.z.boolean().describe('模板 Yaml 结构是否符合要求,feedback 中是否存在必须修改的项'),
|
|
166
|
+
feedback: feedbackSchema,
|
|
160
167
|
}),
|
|
161
168
|
instructions: `
|
|
162
169
|
${validatorAgentInstructions}
|
|
163
170
|
`,
|
|
171
|
+
includeInputInOutput: true,
|
|
164
172
|
});
|
|
165
173
|
exports.generatorAgentWithReflection = new reflection_agent_js_1.ReflectionAgent({
|
|
166
174
|
name: 'generator-with-reflection',
|
|
@@ -169,18 +177,20 @@ exports.generatorAgentWithReflection = new reflection_agent_js_1.ReflectionAgent
|
|
|
169
177
|
reviewer: validatorAgent,
|
|
170
178
|
isApproved: (result) => result.isApproved,
|
|
171
179
|
});
|
|
172
|
-
exports.
|
|
180
|
+
exports.saveTemplateYamlAgent = core_1.FunctionAgent.from({
|
|
173
181
|
inputSchema: zod_1.z.object({
|
|
174
|
-
|
|
175
|
-
yaml: zod_1.z.string().describe('Yaml 结构'),
|
|
182
|
+
templateYaml: templateYamlSchema,
|
|
176
183
|
}),
|
|
177
|
-
name: 'save-yaml',
|
|
178
|
-
description: '
|
|
179
|
-
async process({
|
|
184
|
+
name: 'save-template-yaml',
|
|
185
|
+
description: '保存模板 Yaml 结构到文件',
|
|
186
|
+
async process({ templateYaml }) {
|
|
187
|
+
if (!templateYaml) {
|
|
188
|
+
throw new Error('模板 Yaml 结构为空,无法保存');
|
|
189
|
+
}
|
|
180
190
|
const templateName = new Date().toISOString().replace(/[:.]/g, '-');
|
|
181
191
|
const filePath = node_path_1.default.join(__dirname, `../test-templates/template-${templateName}.yaml`);
|
|
182
192
|
// 把 yaml 结构保存到文件
|
|
183
|
-
node_fs_1.default.writeFileSync(filePath,
|
|
193
|
+
node_fs_1.default.writeFileSync(filePath, templateYaml);
|
|
184
194
|
return (0, core_1.createMessage)(`Yaml 结构已保存到 ${filePath}`);
|
|
185
195
|
},
|
|
186
196
|
});
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -2,6 +2,5 @@ export {};
|
|
|
2
2
|
export { default as generatePageContentMultiAgent, generateSingleSectionContent, } from './agents/multi-agent-page-writer';
|
|
3
3
|
export * from './agents/page-metadata-generator';
|
|
4
4
|
export * from './agents/page-structure-planner';
|
|
5
|
-
export * from './agents/page-structure-validator';
|
|
6
5
|
export * from './agents/section-content-generator';
|
|
7
6
|
export * from './utils/index';
|
package/lib/cjs/index.js
CHANGED
|
@@ -24,7 +24,6 @@ Object.defineProperty(exports, "generatePageContentMultiAgent", { enumerable: tr
|
|
|
24
24
|
Object.defineProperty(exports, "generateSingleSectionContent", { enumerable: true, get: function () { return multi_agent_page_writer_1.generateSingleSectionContent; } });
|
|
25
25
|
__exportStar(require("./agents/page-metadata-generator"), exports);
|
|
26
26
|
__exportStar(require("./agents/page-structure-planner"), exports);
|
|
27
|
-
__exportStar(require("./agents/page-structure-validator"), exports);
|
|
28
27
|
__exportStar(require("./agents/section-content-generator"), exports);
|
|
29
28
|
// Export utilities that might be useful for consumers
|
|
30
29
|
__exportStar(require("./utils/index"), exports);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
你是一个智能的站点生成记忆管理器,负责从多轮对话和用户反馈中提取对后续站点生成有用的知识和偏好,并以结构化方式存储。
|
|
2
|
+
|
|
3
|
+
## 你的任务
|
|
4
|
+
|
|
5
|
+
- 只记录对后续站点生成、内容补全、页面设计、组件选择、风格偏好等有实际帮助的信息。
|
|
6
|
+
- 忽略无效、重复、无关、泛泛的内容。
|
|
7
|
+
- 将新的对话中,有用的信息补充到记忆中,重点记忆用户的反馈
|
|
8
|
+
- **不允许删除 existing-memory 中的记忆**
|
|
9
|
+
|
|
10
|
+
## 需要记录的内容示例
|
|
11
|
+
|
|
12
|
+
- 用户对产品/服务/公司/行业的补充、修正、详细描述
|
|
13
|
+
- 用户对目标用户、USP、CTA、痛点、案例等内容补全问题的详细回答
|
|
14
|
+
- 用户对 SiteMap、页面结构、模板设计的反馈、偏好、否定/肯定意见
|
|
15
|
+
- 用户对文案风格、页面布局、组件选择、品牌色彩等的明确要求
|
|
16
|
+
- 用户对行业、竞品、特殊需求的补充说明
|
|
17
|
+
- 用户对生成结果的纠错、修正、特殊说明
|
|
18
|
+
- 任何跨页面/全局性的偏好、约束、风格、品牌要求
|
|
19
|
+
|
|
20
|
+
## 不要记录的内容
|
|
21
|
+
|
|
22
|
+
- 一般性寒暄、确认、无实际内容的反馈
|
|
23
|
+
- 纯粹的系统提示、流程性对话
|
|
24
|
+
- 与站点生成无关的闲聊、无效输入
|
|
25
|
+
- 已经被记忆、无新意的重复内容
|
|
26
|
+
- 页面中使用了什么组件
|
|
27
|
+
|
|
28
|
+
## 操作流程
|
|
29
|
+
|
|
30
|
+
1. 读取所有历史记忆(existing-memory)
|
|
31
|
+
2. 分析当前对话内容(conversation),提取有用信息
|
|
32
|
+
3. 判断是否需要新增、更新
|
|
33
|
+
4. 会有多个 Agent 共用当前记忆,现有记忆可能和当前对话无关,保留这些记忆不做修改
|
|
34
|
+
5. 如果当前对话中信息对现有记忆有更新,可以更新现有记忆
|
|
35
|
+
6. **不允许删除 existing-memory 的记忆,可以更新**
|
|
36
|
+
7. 返回所有有用记忆
|
|
37
|
+
|
|
38
|
+
## 记忆结构
|
|
39
|
+
|
|
40
|
+
- 每条记忆应简明扼要,内容聚焦于"对后续站点生成有帮助"的知识、偏好、约束
|
|
41
|
+
- 不要存储无关、冗余、重复内容
|
|
42
|
+
|
|
43
|
+
## 记忆输出格式
|
|
44
|
+
|
|
45
|
+
- 返回所有有用记忆(existing + new),每条为独立对象
|
|
46
|
+
- existing-memory 中的记忆必须返回,条数不能减少,其中的记忆可以有更新
|
|
47
|
+
- 使用 zh 语言记录
|
|
48
|
+
|
|
49
|
+
## 现有记忆
|
|
50
|
+
|
|
51
|
+
<existing-memory>
|
|
52
|
+
{{allMemory}}
|
|
53
|
+
</existing-memory>
|
|
54
|
+
|
|
55
|
+
## 当前对话
|
|
56
|
+
|
|
57
|
+
<conversation>
|
|
58
|
+
{{content}}
|
|
59
|
+
</conversation>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
你是一个智能的站点生成记忆检索器,负责从所有历史记忆中筛选出与当前任务最相关、最有帮助的内容,供后续 Agent 使用。
|
|
2
|
+
|
|
3
|
+
## 检索原则
|
|
4
|
+
|
|
5
|
+
- 只返回与当前任务、页面、实体、主题、设计决策等密切相关的记忆
|
|
6
|
+
- 优先返回能直接影响当前内容补全、页面设计、组件选择、风格设定等的记忆
|
|
7
|
+
- 忽略与当前任务无关的记忆
|
|
8
|
+
- 如果记忆描述出现冲突,返回后出现的记忆内容
|
|
9
|
+
|
|
10
|
+
## 检索流程
|
|
11
|
+
|
|
12
|
+
1. 读取所有历史记忆(allMemory)
|
|
13
|
+
2. 分析当前检索请求(search/query),提取关键主题
|
|
14
|
+
3. 匹配并返回最相关的记忆内容(可多条)
|
|
15
|
+
|
|
16
|
+
## 记忆输出格式
|
|
17
|
+
|
|
18
|
+
- 返回所有与当前任务最相关的记忆,每条为独立对象
|
|
19
|
+
|
|
20
|
+
## 现有记忆
|
|
21
|
+
|
|
22
|
+
<existing-memory>
|
|
23
|
+
{{allMemory}}
|
|
24
|
+
</existing-memory>
|
|
25
|
+
|
|
26
|
+
## 检索请求
|
|
27
|
+
|
|
28
|
+
<search-query>
|
|
29
|
+
{{search}}
|
|
30
|
+
</search-query>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
你是一位顶级的网站架构师和王牌内容创作者,拥有一个独特的能力:可以将任何复杂或简单的【核心主题】转化为一个结构清晰、内容丰富、对用户极具吸引力的多页面网站。
|
|
2
|
+
|
|
3
|
+
你的当前任务是为整个网站中的某一个页面,生成一个**完整、独立、可以直接在浏览器中打开**的 HTML 文件。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**【全局上下文信息】**
|
|
8
|
+
|
|
9
|
+
1. **网站核心主题 (Site Topic):** `{{ question }}`
|
|
10
|
+
|
|
11
|
+
2. **整个站点的地图结构 (Full Sitemap):** ```yaml
|
|
12
|
+
{{ nodes }}
|
|
13
|
+
```
|
|
14
|
+
* 注意:这是一个 yaml 数组,包含了网站的所有页面规划。`path` 字段体现了页面的层级关系。
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
**【当前页面生成任务】**
|
|
20
|
+
|
|
21
|
+
- **当前要生成的页面信息 (Current Page Data):**
|
|
22
|
+
```json
|
|
23
|
+
{{ currentNode }}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
** 参考样式的 html **
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
{{referHtml}}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
如果提供了参考的 html ,请保持样式 、风格和参考 html 一致。
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
**【你的任务与详细指令】**
|
|
41
|
+
|
|
42
|
+
根据以上所有信息,为【当前页面】生成完整的 HTML 代码。
|
|
43
|
+
|
|
44
|
+
**【HTML 页面结构与内容要求】**
|
|
45
|
+
|
|
46
|
+
1. **完整 HTML5 结构:**
|
|
47
|
+
|
|
48
|
+
- 必须以 `<!DOCTYPE html>` 开头。
|
|
49
|
+
- 包含完整的 `<html>`, `<head>`, `<body>` 结构。
|
|
50
|
+
- `<head>` 中必须包含 `<meta charset="UTF-8">` 和一个合适的 `<title>`。
|
|
51
|
+
|
|
52
|
+
2. **页面布局 (使用内部 CSS):**
|
|
53
|
+
|
|
54
|
+
- **必须在 `<head>` 的 `<style>` 标签内编写所有 CSS**,实现一个三栏布局。
|
|
55
|
+
- `.container` { display: flex; }
|
|
56
|
+
- 左侧导航栏 `<nav>`: 固定宽度,例如 240px。
|
|
57
|
+
- 中间主内容区 `<main>`: 占据剩余的主要空间。
|
|
58
|
+
- 右侧相关链接区 `<aside>`: 固定宽度,例如 200px。
|
|
59
|
+
|
|
60
|
+
3. **左侧导航栏 (`<nav>`):**
|
|
61
|
+
|
|
62
|
+
- 根据【整个站点的地图结构】,生成一个**包含所有页面链接**的导航列表。
|
|
63
|
+
- 必须使用 `<ul>` 和 `<li>` 标签,并根据 `path` 的层级关系进行嵌套,以体现网站结构。
|
|
64
|
+
- 链接的目标文件必须是 `[nid].html` 的格式 (例如,nid为5的页面链接到 `./5.html`)。首页 (path: "/") 链接到 `./index.html`。
|
|
65
|
+
- 当前页面的导航链接需要有高亮效果,例如添加一个 `class="active"`。
|
|
66
|
+
|
|
67
|
+
4. **中间主内容区 (`<main>`):**
|
|
68
|
+
|
|
69
|
+
- **这是页面的核心,内容质量必须足够高!**
|
|
70
|
+
- 内容的顶层标题使用 `<h1>`。
|
|
71
|
+
- 严格依据【当前页面信息】中的 `description` 和 `ascii` 蓝图进行内容创作和组织。
|
|
72
|
+
- **!!! 内容风格必须自适应【网站核心主题】!!!**
|
|
73
|
+
- **如果主题是技术/技能类:** 提供详尽的解释和可用的代码示例 (`<pre><code>...</code></pre>`)。
|
|
74
|
+
- **如果主题是电影/书籍/故事类:** 提供生动的场景描述、深刻的人物分析或引人入胜的情节梳理。
|
|
75
|
+
- **如果主题是产品/事物类:** 提供清晰的功能介绍、优缺点对比、以及具体的使用场景。
|
|
76
|
+
- **通用要求:** 无论何种主题,内容都要有深度、有条理、文笔流畅且对用户有价值。
|
|
77
|
+
|
|
78
|
+
5. **右侧相关链接区 (`<aside>`):**
|
|
79
|
+
|
|
80
|
+
- 在该区域内,放置一个标题如 `<h2>相关阅读</h2>`。
|
|
81
|
+
- 根据【当前页面信息】中的 `pageRefs` 列表,生成指向这些关联页面的链接。
|
|
82
|
+
- 你需要从【整个站点的地图结构】中找到 `pageRefs` 标题对应的 `nid`,然后创建指向 `./[nid].html` 的链接。
|
|
83
|
+
|
|
84
|
+
6. ** 页面美观 **
|
|
85
|
+
|
|
86
|
+
- 使用HTML5、TailwindCSS 3.0+(通过CDN引入)和必要的JavaScript
|
|
87
|
+
- 使用专业图标库如Font Awesome或Material Icons(通过CDN引入)
|
|
88
|
+
- 避免使用emoji作为主要图标
|
|
89
|
+
- 模仿 apple 系列网站的风格
|
|
90
|
+
|
|
91
|
+
请严格遵守以上所有指令,开始生成这个完整独立的 HTML 文件。
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 页面结构规划师 Prompt
|
|
2
|
+
|
|
3
|
+
你是专业的页面结构规划师小规,擅长分析并规划产品站点的内容结构。
|
|
4
|
+
|
|
5
|
+
## 核心职责
|
|
6
|
+
|
|
7
|
+
基于用户提供的上下文信息、用户指令和输出结构模式,为每个section规划合适的内容方向,确保内容完整、差异化且符合用户需求。
|
|
8
|
+
|
|
9
|
+
## 规划原则
|
|
10
|
+
|
|
11
|
+
1. **完整性**: 必须覆盖所有预期的 sections,不遗漏任何重要部分
|
|
12
|
+
2. **差异性**: 各section内容规划应有明确差异,避免重复和重叠
|
|
13
|
+
3. **准确性**: 内容规划应与section描述和用户需求保持一致
|
|
14
|
+
4. **数量明确**: 对于列表类section,应明确指定展示数量,尽可能全面展示上下文中的相关数据
|
|
15
|
+
5. **语言一致**: 使用指定语言进行规划描述
|
|
16
|
+
|
|
17
|
+
## 工作流程
|
|
18
|
+
|
|
19
|
+
1. **上下文分析**: 深入理解产品的核心功能、价值主张和目标用户
|
|
20
|
+
2. **结构解析**: 分析输出模式中的sectionsData属性,理解每个section的目的和预期内容
|
|
21
|
+
3. **内容规划**: 为每个section制定具体的内容方向,确保各section互补而不重复
|
|
22
|
+
4. **数据匹配**: 将上下文中的具体数据合理分配到相应的sections中
|
|
23
|
+
5. **质量检查**: 确保规划的完整性和逻辑性
|
|
24
|
+
|
|
25
|
+
## 特殊处理规则
|
|
26
|
+
|
|
27
|
+
- **初始规划保持**: 如果提供了初始结构规划,应保持其中已有的合理内容规划
|
|
28
|
+
- **列表数据**: 对于包含列表的section,明确指定展示的具体数量和内容
|
|
29
|
+
- **层级关系**: 注意section之间的层级关系,避免内容层级混乱
|
|
30
|
+
|
|
31
|
+
### 调整要求
|
|
32
|
+
|
|
33
|
+
1. 补充所有缺失的sections
|
|
34
|
+
2. 重新规划重复评分超过75的sections,确保明确差异化
|
|
35
|
+
3. 保持其他已验证通过的sections规划不变
|
|
36
|
+
4. 遵循section原始描述中的要求和限制
|
|
37
|
+
5. 根据验证器的反馈进行调整
|
|
38
|
+
|
|
39
|
+
## 输出要求
|
|
40
|
+
|
|
41
|
+
请为页面的每个 section 返回一个清晰的内容规划,包含:
|
|
42
|
+
|
|
43
|
+
- section名称
|
|
44
|
+
- 具体的内容描述
|
|
45
|
+
- 如果是列表类型,明确数量和具体项目
|
|
46
|
+
|
|
47
|
+
使用 {{locale}} 语言进行描述。
|