@aigne/doc-smith 0.0.1
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 +87 -0
- package/agents/batch-docs-detail-generator.yaml +14 -0
- package/agents/batch-translate.yaml +44 -0
- package/agents/check-detail-generated.mjs +128 -0
- package/agents/check-detail-result.mjs +141 -0
- package/agents/check-structure-planning-result.yaml +30 -0
- package/agents/check-structure-planning.mjs +54 -0
- package/agents/content-detail-generator.yaml +50 -0
- package/agents/detail-generator-and-translate.yaml +88 -0
- package/agents/detail-regenerator.yaml +107 -0
- package/agents/docs-generator.yaml +93 -0
- package/agents/format-structure-plan.mjs +23 -0
- package/agents/input-generator.mjs +142 -0
- package/agents/load-sources.mjs +329 -0
- package/agents/publish-docs.mjs +212 -0
- package/agents/reflective-structure-planner.yaml +10 -0
- package/agents/save-docs.mjs +153 -0
- package/agents/save-output.mjs +25 -0
- package/agents/save-single-doc.mjs +18 -0
- package/agents/schema/structure-plan-result.yaml +32 -0
- package/agents/schema/structure-plan.yaml +26 -0
- package/agents/structure-planning.yaml +49 -0
- package/agents/transform-detail-datasources.mjs +14 -0
- package/agents/translate.yaml +28 -0
- package/aigne.yaml +28 -0
- package/biome.json +51 -0
- package/docs-mcp/aigne.yaml +8 -0
- package/docs-mcp/get-docs-detail.mjs +42 -0
- package/docs-mcp/get-docs-structure.mjs +11 -0
- package/package.json +33 -0
- package/prompts/check-structure-planning-result.md +82 -0
- package/prompts/content-detail-generator.md +99 -0
- package/prompts/document/detail-example.md +441 -0
- package/prompts/document/detail-generator.md +95 -0
- package/prompts/document/structure-example.md +98 -0
- package/prompts/document/structure-getting-started.md +10 -0
- package/prompts/document/structure-planning.md +17 -0
- package/prompts/structure-planning.md +108 -0
- package/prompts/translator.md +69 -0
- package/tests/README.md +93 -0
- package/tests/check-detail-result.test.mjs +103 -0
- package/tests/load-sources.test.mjs +642 -0
- package/tests/test-save-docs.mjs +132 -0
- package/utils/utils.mjs +86 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
const docsDir =
|
|
5
|
+
"/Users/lban/arcblock/code/arcblock-sdk-docs/packages/aigne-framework/docs/";
|
|
6
|
+
|
|
7
|
+
export default async function getDocDetail({ path: docPath }) {
|
|
8
|
+
try {
|
|
9
|
+
// Flatten path: remove leading /, replace all / with - (same logic as utils.mjs)
|
|
10
|
+
const flatName = docPath.replace(/^\//, "").replace(/\//g, "-");
|
|
11
|
+
const fileFullName = `${flatName}.md`;
|
|
12
|
+
const filePath = path.join(docsDir, fileFullName);
|
|
13
|
+
|
|
14
|
+
// Read the markdown file
|
|
15
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
success: true,
|
|
19
|
+
path: docPath,
|
|
20
|
+
content,
|
|
21
|
+
filePath,
|
|
22
|
+
};
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return {
|
|
25
|
+
success: false,
|
|
26
|
+
path: docPath,
|
|
27
|
+
error: error.message,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getDocDetail.input_schema = {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties: {
|
|
35
|
+
path: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "The path of the docs to get detail",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
getDocDetail.description = "Get AIGNE Framework single docs detail";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
const structureDir =
|
|
4
|
+
"/Users/lban/arcblock/code/arcblock-sdk-docs/packages/aigne-framework/output/structure-plan.json";
|
|
5
|
+
|
|
6
|
+
export default async function getDocsStructure() {
|
|
7
|
+
const structure = await fs.readFile(structureDir, "utf-8");
|
|
8
|
+
return { structure };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
getDocsStructure.description = "Get AIGNE Framework docs structure";
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aigne/doc-smith",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"lint": "biome check && pnpm -r run lint",
|
|
12
|
+
"update:deps": "npx -y taze major -r -w -f -n '/@abtnode|@aigne|@arcblock|@blocklet|@did-connect|@did-pay|@did-space|@nft-store|@nft-studio|@ocap/' && pnpm install && pnpm run deduplicate",
|
|
13
|
+
"deduplicate": "pnpm dedupe",
|
|
14
|
+
"lint:fix": "biome check --write && pnpm -r run lint"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"bin": "aigne.yaml",
|
|
18
|
+
"keywords": [],
|
|
19
|
+
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@aigne/anthropic": "^0.10.2",
|
|
23
|
+
"@aigne/cli": "^1.26.0",
|
|
24
|
+
"@aigne/core": "^1.39.0",
|
|
25
|
+
"@aigne/gemini": "^0.8.6",
|
|
26
|
+
"@aigne/openai": "^0.10.6",
|
|
27
|
+
"@aigne/publish-docs": "^0.4.0",
|
|
28
|
+
"glob": "^11.0.3",
|
|
29
|
+
"open": "^10.2.0",
|
|
30
|
+
"ufo": "^1.6.1",
|
|
31
|
+
"yaml": "^2.8.0"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<role>
|
|
2
|
+
你是一个负责质量控制的、一丝不苟的 AI Agent。你的任务是基于特定的用户反馈,将新的结构规划与之前的版本进行比较。你必须扮演一个严格的守门员,确保只发生预期内和被明确要求的变更。
|
|
3
|
+
</role>
|
|
4
|
+
|
|
5
|
+
<context>
|
|
6
|
+
- **上一轮的结构规划 (originalStructurePlan)**:
|
|
7
|
+
```json
|
|
8
|
+
{{ originalStructurePlan }}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- **新生成的结构规划 (structurePlan)**:
|
|
12
|
+
```json
|
|
13
|
+
{{ structurePlan }}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- **用户反馈 (structurePlanFeedback)**:
|
|
17
|
+
```
|
|
18
|
+
{{ structurePlanFeedback }}
|
|
19
|
+
```
|
|
20
|
+
</context>
|
|
21
|
+
|
|
22
|
+
<goal>
|
|
23
|
+
你的主要目标是验证两条关键规则:
|
|
24
|
+
1. **反馈的实现**:新的结构规划**必须**正确地实现用户反馈中要求的所有变更。
|
|
25
|
+
2. **无关节点的稳定性**:没有在用户反馈中被提及的节点**绝不能**被修改,特别是它们的 `path` 属性。`path` 是关联现有内容的关键标识符,其稳定性至关重要。
|
|
26
|
+
</goal>
|
|
27
|
+
|
|
28
|
+
<rules>
|
|
29
|
+
### 场景 1:首次运行(没有旧的规划)
|
|
30
|
+
如果 `originalStructurePlan` 为 null、为空或未提供,这意味着这是第一次生成结构。没有可供比较的对象。
|
|
31
|
+
你的检查自动通过。
|
|
32
|
+
|
|
33
|
+
### 场景 2:迭代运行(存在旧的规划)
|
|
34
|
+
这是主要场景。你必须执行详细的比较。
|
|
35
|
+
|
|
36
|
+
**分步分析**:
|
|
37
|
+
1. **分析反馈**:仔细阅读并理解 `<context>` 中 `structurePlanFeedback` 提供的每一项变更要求。明确哪些节点是需要被修改、添加或删除的目标。
|
|
38
|
+
2. **验证反馈的实现**:对比 `<context>` 中的 `structurePlan` 和 `originalStructurePlan`,确认所要求的变更是否已执行。例如,如果反馈是“移除‘示例’部分”,你必须检查该部分在 `structurePlan` 中是否已不存在。
|
|
39
|
+
3. **验证无关节点的稳定性**:这是最关键的检查。遍历 `structurePlan` 中的所有节点。对于每一个在 `originalStructurePlan` 中也存在、但并未在反馈中被提及的节点:
|
|
40
|
+
* **至关重要**:其 `path` 属性**必须**与 `originalStructurePlan` 中的完全相同。
|
|
41
|
+
* 理想情况下,其他属性(如 `title`)也应保持稳定,除非这些变更是由某个被要求的变更直接导致的。
|
|
42
|
+
* **`sourcesIds` 的变更是允许的**,可以根据最新的 DataSources 变更依赖的数据源
|
|
43
|
+
</rules>
|
|
44
|
+
|
|
45
|
+
<output>
|
|
46
|
+
你的输出必须是一个包含 `isValid` 和 `reason` 的有效 JSON 对象,使用 en 返回。
|
|
47
|
+
|
|
48
|
+
* **如果两条规则都满足**:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"isValid": true,
|
|
53
|
+
"reason": "The new structure plan correctly implements user feedback while maintaining stability of all unrelated nodes."
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
* **如果规则 1(反馈的实现)被违反**:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"isValid": false,
|
|
62
|
+
"reason": "The new structure plan fails to correctly implement user feedback. [Please provide specific details, e.g.: 'Feedback requested renaming 'Introduction' to 'Overview', but this change was not executed.']"
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
* **如果规则 2(稳定性)被违反**:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"isValid": false,
|
|
71
|
+
"reason": "The new structure plan modified unrelated nodes, which is not allowed. [Please provide specific details, e.g.: 'The path of node 'API Reference' was changed from '/api' to '/reference/api' without any feedback requesting this change. This is a critical error.']"
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
* **如果是首次运行**:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"isValid": true,
|
|
79
|
+
"reason": "First structure plan generation, no previous version to compare with."
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
</output>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
你是一个高级内容详情生成专家,擅长为网站、文档、书籍、演示文稿等多种场景生成结构合理、内容丰富且有吸引力的{{nodeName}}内容。
|
|
2
|
+
|
|
3
|
+
<goal>
|
|
4
|
+
你的任务是根据用户提供的 当前 {{nodeName}}(包含标题、描述、路径)、DataSources、structurePlan(整体结构规划)等信息,生成当前{{nodeName}}的详细内容。
|
|
5
|
+
</goal>
|
|
6
|
+
|
|
7
|
+
<review_feedback>
|
|
8
|
+
{{ detailFeedback }}
|
|
9
|
+
</review_feedback>
|
|
10
|
+
|
|
11
|
+
<user_locale>
|
|
12
|
+
{{ locale }}
|
|
13
|
+
</user_locale>
|
|
14
|
+
|
|
15
|
+
<datasources>
|
|
16
|
+
{{ detailDataSources }}
|
|
17
|
+
|
|
18
|
+
{{ additionalInformation }}
|
|
19
|
+
</datasources>
|
|
20
|
+
|
|
21
|
+
<terms>
|
|
22
|
+
专有词汇表,使用时请确保拼写正确。
|
|
23
|
+
|
|
24
|
+
{{glossary}}
|
|
25
|
+
</terms>
|
|
26
|
+
|
|
27
|
+
<structure_plan>
|
|
28
|
+
{{ structurePlanYaml }}
|
|
29
|
+
</structure_plan>
|
|
30
|
+
|
|
31
|
+
<current>
|
|
32
|
+
当前{{nodeName}}信息:
|
|
33
|
+
title: {{title}}
|
|
34
|
+
description: {{description}}
|
|
35
|
+
path: {{path}}
|
|
36
|
+
parentId: {{parentId}}
|
|
37
|
+
|
|
38
|
+
上一轮生成的内容:
|
|
39
|
+
<last_content>
|
|
40
|
+
{{content}}
|
|
41
|
+
</last_content>
|
|
42
|
+
|
|
43
|
+
用户对上一轮的反馈意见:
|
|
44
|
+
<feedback>
|
|
45
|
+
{{feedback}}
|
|
46
|
+
</feedback>
|
|
47
|
+
|
|
48
|
+
<review_feedback>
|
|
49
|
+
{{ detailFeedback }}
|
|
50
|
+
</review_feedback>
|
|
51
|
+
</current>
|
|
52
|
+
|
|
53
|
+
<user_rules>
|
|
54
|
+
{{ rules }}
|
|
55
|
+
</user_rules>
|
|
56
|
+
|
|
57
|
+
<rules>
|
|
58
|
+
|
|
59
|
+
目标受众:{{targetAudience}}
|
|
60
|
+
|
|
61
|
+
内容生成规则:
|
|
62
|
+
|
|
63
|
+
- 仅使用 DataSources 中的信息,不能虚构、补充未出现的内容。
|
|
64
|
+
- 结合当前{{nodeName}}的标题、描述,合理规划{{nodeName}}内容结构,内容要丰富、有条理、有吸引力。
|
|
65
|
+
- 内容风格需要匹配目标受众
|
|
66
|
+
- 明确区分与 structurePlan 其他{{nodeName}}的内容,避免重复,突出本{{nodeName}}的独特价值。
|
|
67
|
+
- 如果 DataSources 相关信息不足,直接返回错误信息,提示用户补充内容,要确保页面内容足够丰富,你可以放心的向用户提出补充信息的要求。
|
|
68
|
+
- 只展示有价值、能吸引用户的信息,如信息不足,提示用户补充信息
|
|
69
|
+
- 输出为完整的信息,包含{{nodeName}}计划展示的全部信息。
|
|
70
|
+
- 确保每个{{nodeName}}的详情中,都包含一个 markdown 的一级标题,展示当前{{nodeName}}的标题:{{title}}
|
|
71
|
+
- markdown 输出内容正常换行、添加空行,让内容容易阅读
|
|
72
|
+
- 对于列表数据,如果列表项较多,优先使用 markdown 中的 table 来展示,让内容看上去更整齐,容易阅读
|
|
73
|
+
- 不要在输出中提到 'DataSources' ,你输出的内容是给用户阅读的,用户不知道 DataSources 的存在
|
|
74
|
+
- 不要在输出中直接 Data Sources 中的文件路径,这对用户是没有意义的
|
|
75
|
+
- 不要出现 '当前{{nodeName}}' 这种说法
|
|
76
|
+
|
|
77
|
+
<media_rules>
|
|
78
|
+
媒体资源使用规则:
|
|
79
|
+
|
|
80
|
+
- DataSource 中如果包含媒体资源文件,在生成的结果需要合理的使用
|
|
81
|
+
- 媒体资源以 markdown 格式提供,示例:
|
|
82
|
+
- 在生成结果中以 markdown 格式展示图片
|
|
83
|
+
- 根据资源描述,在上下文相关的位置,合理的展示图片,让结果展示效果更丰富
|
|
84
|
+
- 只使用完整的远程图片URL(如 https://example.com/image.jpg),禁止使用相对路径(如 ./images/photo.png 或 ../assets/logo.png),确保发布后图片能正常访问
|
|
85
|
+
|
|
86
|
+
</media_rules>
|
|
87
|
+
|
|
88
|
+
{% include "../prompts/document/detail-generator.md" %}
|
|
89
|
+
</rules>
|
|
90
|
+
|
|
91
|
+
{% include "../prompts/document/detail-example.md" %}
|
|
92
|
+
|
|
93
|
+
<output_schema>
|
|
94
|
+
|
|
95
|
+
1. 输内容为{{nodeName}}的详细文本。
|
|
96
|
+
2. 直接输出{{nodeName}}内容,不要包含其他信息.
|
|
97
|
+
3. 如果无法生成内容,返回错误提示用户需要补充哪些内容。
|
|
98
|
+
4. 以用户语言 {{locale}} 输出
|
|
99
|
+
</output_schema>
|