@aigne/doc-smith 0.8.15-beta.6 → 0.8.15-beta.8
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/CHANGELOG.md +20 -0
- package/agents/clear/choose-contents.mjs +4 -4
- package/agents/clear/clear-auth-tokens.mjs +8 -8
- package/agents/clear/clear-deployment-config.mjs +2 -2
- package/agents/clear/clear-document-config.mjs +3 -3
- package/agents/clear/clear-document-structure.mjs +10 -10
- package/agents/clear/clear-generated-docs.mjs +103 -14
- package/agents/clear/clear-media-description.mjs +7 -7
- package/agents/generate/check-need-generate-structure.mjs +2 -7
- package/agents/generate/generate-structure.yaml +159 -65
- package/agents/generate/user-review-document-structure.mjs +1 -0
- package/agents/generate/utils/merge-document-structures.mjs +54 -0
- package/agents/schema/document-structure-item.yaml +23 -0
- package/agents/schema/document-structure.yaml +1 -3
- package/agents/translate/index.yaml +1 -1
- package/agents/translate/record-translation-history.mjs +6 -2
- package/agents/update/save-and-translate-document.mjs +11 -0
- package/agents/utils/choose-docs.mjs +2 -1
- package/agents/utils/load-sources.mjs +55 -38
- package/agents/utils/save-doc.mjs +0 -9
- package/aigne.yaml +2 -4
- package/package.json +2 -1
- package/prompts/detail/custom/custom-components.md +38 -3
- package/prompts/structure/generate/system-prompt.md +0 -30
- package/prompts/structure/generate/user-prompt.md +68 -27
- package/prompts/structure/review/structure-review-system.md +73 -0
- package/prompts/translate/code-block.md +13 -3
- package/types/document-structure-schema.mjs +3 -3
- package/utils/docs-finder-utils.mjs +48 -0
- package/utils/extract-api.mjs +32 -0
- package/utils/file-utils.mjs +14 -87
- package/utils/history-utils.mjs +20 -8
- package/agents/generate/document-structure-tools/generate-sub-structure.mjs +0 -131
- package/agents/generate/generate-structure-without-tools.yaml +0 -65
|
@@ -140,6 +140,7 @@ export default async function userReviewDocumentStructure({ documentStructure, .
|
|
|
140
140
|
// Call refineDocumentStructure agent with feedback
|
|
141
141
|
await options.context.invoke(refineAgent, {
|
|
142
142
|
...rest,
|
|
143
|
+
datasources: rest.datasources[0].datasources,
|
|
143
144
|
feedback: feedback.trim(),
|
|
144
145
|
documentStructure: currentStructure,
|
|
145
146
|
userPreferences,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export default async function mergeDocumentStructures(input, options) {
|
|
2
|
+
if (input.projectName) {
|
|
3
|
+
options.context.userContext.projectName = input.projectName;
|
|
4
|
+
}
|
|
5
|
+
if (input.projectDesc) {
|
|
6
|
+
options.context.userContext.projectDesc = input.projectDesc;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
input.projectName = options.context.userContext.projectName;
|
|
10
|
+
input.projectDesc = options.context.userContext.projectDesc;
|
|
11
|
+
|
|
12
|
+
options.context.userContext.originalDocumentStructure ??= [];
|
|
13
|
+
|
|
14
|
+
const structure = options.context.userContext.originalDocumentStructure;
|
|
15
|
+
|
|
16
|
+
if (input.add) {
|
|
17
|
+
for (const { index, item } of input.add) {
|
|
18
|
+
if (index != null && index >= 0 && index < structure.length) {
|
|
19
|
+
structure.splice(index, 0, item);
|
|
20
|
+
} else {
|
|
21
|
+
structure.push(item);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (input.update) {
|
|
27
|
+
for (const upd of input.update) {
|
|
28
|
+
const idx = structure.findIndex((i) => i.path === upd.path);
|
|
29
|
+
if (idx !== -1) {
|
|
30
|
+
structure[idx] = upd.item;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (input.delete) {
|
|
36
|
+
for (const del of input.delete) {
|
|
37
|
+
const idx = structure.findIndex((i) => i.path === del.path);
|
|
38
|
+
if (idx !== -1) {
|
|
39
|
+
structure.splice(idx, 1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
options.context.userContext.originalDocumentStructure = structure.map((i, index) => {
|
|
45
|
+
delete i.index;
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
index,
|
|
49
|
+
...i,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type: object
|
|
2
|
+
description: Document structure item representing a node in the document hierarchy
|
|
3
|
+
properties:
|
|
4
|
+
title:
|
|
5
|
+
type: string
|
|
6
|
+
description:
|
|
7
|
+
type: string
|
|
8
|
+
path:
|
|
9
|
+
type: string
|
|
10
|
+
description: Path in URL format, cannot be empty, cannot contain spaces or special characters, must start with /, no need to include language level, e.g., /zh/about should return /about
|
|
11
|
+
parentPath:
|
|
12
|
+
type: string
|
|
13
|
+
description: Parent node path, if null indicates it is a top-level node
|
|
14
|
+
sourceIds:
|
|
15
|
+
type: array
|
|
16
|
+
description: Associated sourceId from dataSources for subsequent translation and content generation, must come from sourceId in datasources, cannot have fake ids, **cannot be empty**
|
|
17
|
+
items:
|
|
18
|
+
type: string
|
|
19
|
+
required:
|
|
20
|
+
- title
|
|
21
|
+
- description
|
|
22
|
+
- path
|
|
23
|
+
- sourceIds
|
|
@@ -10,9 +10,7 @@ items:
|
|
|
10
10
|
type: string
|
|
11
11
|
description: Path in URL format, cannot be empty, cannot contain spaces or special characters, must start with /, no need to include language level, e.g., /zh/about should return /about
|
|
12
12
|
parentId:
|
|
13
|
-
type:
|
|
14
|
-
- string
|
|
15
|
-
- "null"
|
|
13
|
+
type: string
|
|
16
14
|
description: Parent node path, if null indicates it is a top-level node
|
|
17
15
|
sourceIds:
|
|
18
16
|
type: array
|
|
@@ -33,12 +33,12 @@ skills:
|
|
|
33
33
|
name: batchTranslateDocument
|
|
34
34
|
skills:
|
|
35
35
|
- ../translate/translate-multilingual.yaml
|
|
36
|
-
- url: ./record-translation-history.mjs
|
|
37
36
|
iterate_on: selectedDocs
|
|
38
37
|
concurrency: 10
|
|
39
38
|
- url: ../utils/check-feedback-refiner.mjs
|
|
40
39
|
default_input:
|
|
41
40
|
stage: translation_refine
|
|
41
|
+
- url: ./record-translation-history.mjs
|
|
42
42
|
- url: ../utils/action-success.mjs
|
|
43
43
|
default_input:
|
|
44
44
|
action: '✅ Translation completed'
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { recordUpdate } from "../../utils/history-utils.mjs";
|
|
2
2
|
|
|
3
|
-
export default function recordTranslationHistory({
|
|
3
|
+
export default function recordTranslationHistory({ selectedPaths, feedback }) {
|
|
4
4
|
// Skip if no feedback provided
|
|
5
5
|
if (!feedback?.trim()) {
|
|
6
6
|
return {};
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
if (!Array.isArray(selectedPaths) || selectedPaths.length === 0) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
// Record translation history for this document
|
|
10
14
|
recordUpdate({
|
|
11
15
|
operation: "translation_update",
|
|
12
16
|
feedback: feedback.trim(),
|
|
13
|
-
|
|
17
|
+
docPaths: selectedPaths,
|
|
14
18
|
});
|
|
15
19
|
|
|
16
20
|
return {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import pMap from "p-map";
|
|
2
|
+
import { recordUpdate } from "../../utils/history-utils.mjs";
|
|
2
3
|
|
|
3
4
|
export default async function saveAndTranslateDocument(input, options) {
|
|
4
5
|
const { selectedDocs, docsDir, translateLanguages, locale } = input;
|
|
@@ -7,6 +8,16 @@ export default async function saveAndTranslateDocument(input, options) {
|
|
|
7
8
|
return {};
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
// Record history if feedback is provided
|
|
12
|
+
const doc = selectedDocs[0];
|
|
13
|
+
if (doc.feedback?.trim()) {
|
|
14
|
+
recordUpdate({
|
|
15
|
+
operation: "document_update",
|
|
16
|
+
feedback: doc.feedback.trim(),
|
|
17
|
+
docPaths: selectedDocs.map((v) => v.path),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
// Only prompt user if translation is actually needed
|
|
11
22
|
let shouldTranslate = false;
|
|
12
23
|
if (
|
|
@@ -18,6 +18,7 @@ export default async function chooseDocs(
|
|
|
18
18
|
locale,
|
|
19
19
|
reset = false,
|
|
20
20
|
requiredFeedback = true,
|
|
21
|
+
title,
|
|
21
22
|
},
|
|
22
23
|
options,
|
|
23
24
|
) {
|
|
@@ -65,7 +66,7 @@ export default async function chooseDocs(
|
|
|
65
66
|
|
|
66
67
|
// Let user select multiple files
|
|
67
68
|
selectedFiles = await options.prompts.checkbox({
|
|
68
|
-
message: getActionText(isTranslate, "Select documents to {action}:"),
|
|
69
|
+
message: title || getActionText(isTranslate, "Select documents to {action}:"),
|
|
69
70
|
source: (term) => {
|
|
70
71
|
if (!term) return choices;
|
|
71
72
|
|
|
@@ -4,11 +4,11 @@ import path from "node:path";
|
|
|
4
4
|
import imageSize from "image-size";
|
|
5
5
|
import {
|
|
6
6
|
buildSourcesContent,
|
|
7
|
-
calculateFileStats,
|
|
8
7
|
loadFilesFromPaths,
|
|
9
8
|
readFileContents,
|
|
10
9
|
getMimeType,
|
|
11
10
|
isRemoteFile,
|
|
11
|
+
calculateTokens,
|
|
12
12
|
} from "../../utils/file-utils.mjs";
|
|
13
13
|
import {
|
|
14
14
|
getCurrentGitHead,
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
DEFAULT_INCLUDE_PATTERNS,
|
|
22
22
|
} from "../../utils/constants/index.mjs";
|
|
23
23
|
import { isOpenAPISpecFile } from "../../utils/openapi/index.mjs";
|
|
24
|
+
import { loadDocumentStructure } from "../../utils/docs-finder-utils.mjs";
|
|
24
25
|
|
|
25
26
|
export default async function loadSources(
|
|
26
27
|
{
|
|
@@ -195,13 +196,10 @@ export default async function loadSources(
|
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
// Read all source files using the utility function
|
|
198
|
-
let sourceFiles = await readFileContents(sourceFilesPaths, process.cwd())
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
// check if totalTokens is too large
|
|
204
|
-
const isLargeContext = totalTokens > INTELLIGENT_SUGGESTION_TOKEN_THRESHOLD;
|
|
199
|
+
let sourceFiles = (await readFileContents(sourceFilesPaths, process.cwd())).map((i) => ({
|
|
200
|
+
...i,
|
|
201
|
+
tokens: calculateTokens(`\n${i.sourceId}\n${i.content}`),
|
|
202
|
+
}));
|
|
205
203
|
|
|
206
204
|
// filter OpenAPI doc should after check isLargeContext
|
|
207
205
|
sourceFiles = sourceFiles.filter((file) => {
|
|
@@ -214,6 +212,16 @@ export default async function loadSources(
|
|
|
214
212
|
return !isOpenAPI;
|
|
215
213
|
});
|
|
216
214
|
|
|
215
|
+
const totalTokens = sourceFiles.reduce((sum, file) => sum + file.tokens, 0);
|
|
216
|
+
const totalLines = sourceFiles.reduce(
|
|
217
|
+
(sum, file) => sum + file.content.split("\n").filter(Boolean).length,
|
|
218
|
+
0,
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
const datasources = splitSourcesToChunks(sourceFiles, INTELLIGENT_SUGGESTION_TOKEN_THRESHOLD).map(
|
|
222
|
+
(i) => ({ datasources: buildSourcesContent(i) }),
|
|
223
|
+
);
|
|
224
|
+
|
|
217
225
|
const remoteFileList = [];
|
|
218
226
|
|
|
219
227
|
sourceFiles.forEach((file) => {
|
|
@@ -225,37 +233,11 @@ export default async function loadSources(
|
|
|
225
233
|
options.context.userContext.remoteFileList = remoteFileList;
|
|
226
234
|
}
|
|
227
235
|
|
|
228
|
-
// Build allSources string using utility function
|
|
229
|
-
const allSources = buildSourcesContent(sourceFiles, isLargeContext);
|
|
230
236
|
// all files path
|
|
231
237
|
const allFilesPaths = sourceFiles.map((x) => `- ${toRelativePath(x.sourceId)}`).join("\n");
|
|
232
238
|
|
|
233
239
|
// Get the last documentation structure
|
|
234
|
-
|
|
235
|
-
if (outputDir) {
|
|
236
|
-
const documentStructurePath = path.join(outputDir, "structure-plan.json");
|
|
237
|
-
try {
|
|
238
|
-
const documentExecutionStructure = await readFile(documentStructurePath, "utf8");
|
|
239
|
-
if (documentExecutionStructure?.trim()) {
|
|
240
|
-
try {
|
|
241
|
-
// Validate that the content looks like JSON before parsing
|
|
242
|
-
const trimmedContent = documentExecutionStructure.trim();
|
|
243
|
-
if (trimmedContent.startsWith("{") || trimmedContent.startsWith("[")) {
|
|
244
|
-
originalDocumentStructure = JSON.parse(documentExecutionStructure);
|
|
245
|
-
} else {
|
|
246
|
-
console.warn(`structure-plan.json contains non-JSON content, skipping parse`);
|
|
247
|
-
}
|
|
248
|
-
} catch (err) {
|
|
249
|
-
console.error(`Failed to parse structure-plan.json: ${err.message}`);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
} catch (err) {
|
|
253
|
-
if (err.code !== "ENOENT") {
|
|
254
|
-
console.warn(`Error reading structure-plan.json: ${err.message}`);
|
|
255
|
-
}
|
|
256
|
-
// The file does not exist or is not readable, originalDocumentStructure remains undefined
|
|
257
|
-
}
|
|
258
|
-
}
|
|
240
|
+
const originalDocumentStructure = await loadDocumentStructure(outputDir);
|
|
259
241
|
|
|
260
242
|
// Get the last output result of the specified path
|
|
261
243
|
let content;
|
|
@@ -308,7 +290,7 @@ export default async function loadSources(
|
|
|
308
290
|
}
|
|
309
291
|
|
|
310
292
|
return {
|
|
311
|
-
datasources
|
|
293
|
+
datasources,
|
|
312
294
|
content,
|
|
313
295
|
originalDocumentStructure,
|
|
314
296
|
files,
|
|
@@ -316,7 +298,6 @@ export default async function loadSources(
|
|
|
316
298
|
totalTokens,
|
|
317
299
|
totalLines,
|
|
318
300
|
mediaFiles,
|
|
319
|
-
isLargeContext,
|
|
320
301
|
allFilesPaths,
|
|
321
302
|
};
|
|
322
303
|
}
|
|
@@ -365,7 +346,13 @@ loadSources.output_schema = {
|
|
|
365
346
|
type: "object",
|
|
366
347
|
properties: {
|
|
367
348
|
datasources: {
|
|
368
|
-
type: "
|
|
349
|
+
type: "array",
|
|
350
|
+
items: {
|
|
351
|
+
type: "object",
|
|
352
|
+
properties: {
|
|
353
|
+
datasources: { type: "string" },
|
|
354
|
+
},
|
|
355
|
+
},
|
|
369
356
|
},
|
|
370
357
|
files: {
|
|
371
358
|
type: "array",
|
|
@@ -396,3 +383,33 @@ loadSources.output_schema = {
|
|
|
396
383
|
};
|
|
397
384
|
|
|
398
385
|
loadSources.task_render_mode = "hide";
|
|
386
|
+
|
|
387
|
+
function splitSourcesToChunks(sources, maxTokens) {
|
|
388
|
+
const chunks = [];
|
|
389
|
+
|
|
390
|
+
let currentChunk = [];
|
|
391
|
+
let currentTokens = 0;
|
|
392
|
+
|
|
393
|
+
for (const source of sources) {
|
|
394
|
+
const sourceTokens = source.tokens;
|
|
395
|
+
|
|
396
|
+
if (currentTokens + sourceTokens > maxTokens) {
|
|
397
|
+
// Start a new chunk
|
|
398
|
+
if (currentChunk.length > 0) {
|
|
399
|
+
chunks.push(currentChunk);
|
|
400
|
+
}
|
|
401
|
+
currentChunk = [source];
|
|
402
|
+
currentTokens = sourceTokens;
|
|
403
|
+
} else {
|
|
404
|
+
// Add to current chunk
|
|
405
|
+
currentChunk.push(source);
|
|
406
|
+
currentTokens += sourceTokens;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (currentChunk.length > 0) {
|
|
411
|
+
chunks.push(currentChunk);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return chunks;
|
|
415
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { recordUpdate } from "../../utils/history-utils.mjs";
|
|
2
1
|
import { shutdownMermaidWorkerPool } from "../../utils/mermaid-worker-pool.mjs";
|
|
3
2
|
import { saveDoc as _saveDoc } from "../../utils/utils.mjs";
|
|
4
3
|
|
|
@@ -20,14 +19,6 @@ export default async function saveDoc({
|
|
|
20
19
|
locale,
|
|
21
20
|
});
|
|
22
21
|
|
|
23
|
-
if (feedback?.trim()) {
|
|
24
|
-
recordUpdate({
|
|
25
|
-
operation: "document_update",
|
|
26
|
-
feedback: feedback.trim(),
|
|
27
|
-
documentPath: path,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
22
|
if (isShowMessage) {
|
|
32
23
|
// Shutdown mermaid worker pool to ensure clean exit
|
|
33
24
|
try {
|
package/aigne.yaml
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env aigne
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
name: gemini-2.5-pro
|
|
3
|
+
model:
|
|
4
|
+
model: google/gemini-2.5-pro
|
|
6
5
|
# name: gemini-2.5-flash
|
|
7
6
|
temperature: 0.8
|
|
8
7
|
agents:
|
|
@@ -11,7 +10,6 @@ agents:
|
|
|
11
10
|
|
|
12
11
|
# Documentation Structure Generation
|
|
13
12
|
- ./agents/generate/generate-structure.yaml
|
|
14
|
-
- ./agents/generate/generate-structure-without-tools.yaml
|
|
15
13
|
- ./agents/generate/update-document-structure.yaml
|
|
16
14
|
- ./agents/generate/check-need-generate-structure.mjs
|
|
17
15
|
- ./agents/generate/refine-document-structure.yaml
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/doc-smith",
|
|
3
|
-
"version": "0.8.15-beta.
|
|
3
|
+
"version": "0.8.15-beta.8",
|
|
4
4
|
"description": "AI-driven documentation generation tool built on the AIGNE Framework",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"remark-lint": "^10.0.1",
|
|
57
57
|
"remark-parse": "^11.0.0",
|
|
58
58
|
"terminal-link": "^4.0.0",
|
|
59
|
+
"typescript": "^5.9.3",
|
|
59
60
|
"ufo": "^1.6.1",
|
|
60
61
|
"unified": "^11.0.5",
|
|
61
62
|
"unist-util-visit": "^5.0.0",
|
|
@@ -72,12 +72,11 @@ Suitable for displaying multiple links using a card list format, providing a ric
|
|
|
72
72
|
|
|
73
73
|
### Attributes
|
|
74
74
|
|
|
75
|
-
- data-columns (optional):
|
|
76
|
-
- Must contain multiple <x-card> elements internally.
|
|
75
|
+
- data-columns (optional): Must be an **integer ≥ 2**. Values below 2 are disallowed. Default is 2.
|
|
77
76
|
|
|
78
77
|
### Children
|
|
79
78
|
|
|
80
|
-
- Must contain multiple
|
|
79
|
+
- Must contain multiple `<x-card>` elements internally.
|
|
81
80
|
|
|
82
81
|
### Usage Rules
|
|
83
82
|
|
|
@@ -107,6 +106,25 @@ Example 2: Two-column cards with images
|
|
|
107
106
|
</x-cards>
|
|
108
107
|
```
|
|
109
108
|
|
|
109
|
+
### Bad Examples
|
|
110
|
+
|
|
111
|
+
Example 1: Using a single-column layout (`data-columns="1"`) is not allowed
|
|
112
|
+
|
|
113
|
+
```md
|
|
114
|
+
<x-cards data-columns="1">
|
|
115
|
+
<x-card data-title="Feature 1" data-icon="lucide:rocket">Description of Feature 1.</x-card>
|
|
116
|
+
<x-card data-title="Feature 2" data-icon="lucide:bolt">Description of Feature 2.</x-card>
|
|
117
|
+
</x-cards>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Example 2: Contains only one `<x-card>` (must include multiple cards)
|
|
121
|
+
|
|
122
|
+
```md
|
|
123
|
+
<x-cards data-columns="2">
|
|
124
|
+
<x-card data-title="Card A" data-image="https://picsum.photos/id/10/300/300">Content A</x-card>
|
|
125
|
+
</x-cards>
|
|
126
|
+
```
|
|
127
|
+
|
|
110
128
|
## XField: Structured data field
|
|
111
129
|
|
|
112
130
|
Suitable for displaying API parameters, return values, context data, and any structured data with metadata in a clean, organized format. Supports nested structures for complex data types.
|
|
@@ -414,6 +432,7 @@ Used to group multiple related `<x-field>` elements at the top level, indicating
|
|
|
414
432
|
|
|
415
433
|
- **Top-Level Only**: Used only at the top level for grouping related `<x-field>` elements. Cannot be nested inside other `<x-field>` or `<x-field-group>` elements
|
|
416
434
|
- **Structured Data Only**: Use `<x-field-group>` for fields **other than simple types** (`string`, `number`, `boolean`, `symbol`), e.g., Properties, Context, Parameters, Return values. For simple-type fields, use plain Markdown text.
|
|
435
|
+
- **Spacing Around**: Always insert a blank line before and after `<x-field-group>` when it’s adjacent to Markdown content.
|
|
417
436
|
|
|
418
437
|
### Good Examples
|
|
419
438
|
|
|
@@ -482,4 +501,20 @@ Example 5: Using x-field-group for simple-type (violates "Structured Data Only"
|
|
|
482
501
|
</x-field-group>
|
|
483
502
|
```
|
|
484
503
|
|
|
504
|
+
Example 6: Missing blank line before x-field-group (violates "Spacing Around" rule)
|
|
505
|
+
|
|
506
|
+
```md
|
|
507
|
+
**Parameters**
|
|
508
|
+
<x-field-group>
|
|
509
|
+
<x-field data-name="initialState" data-type="any" data-required="false">
|
|
510
|
+
<x-field-desc markdown>The initial state value.</x-field-desc>
|
|
511
|
+
</x-field>
|
|
512
|
+
</x-field-group>
|
|
513
|
+
|
|
514
|
+
`useReducer` returns an array with two items:
|
|
515
|
+
<x-field-group>
|
|
516
|
+
<x-field data-name="dispatch" data-type="function" data-desc="A function that you can call with an action to update the state."></x-field>
|
|
517
|
+
</x-field-group>
|
|
518
|
+
```
|
|
519
|
+
|
|
485
520
|
</custom_components_usage>
|
|
@@ -14,34 +14,4 @@ You are an AI document strategist with the personality of an **INTJ (The Archite
|
|
|
14
14
|
{% include "../../common/document-structure/conflict-resolution-guidance.md" %}
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
<sub_structure>
|
|
18
|
-
{% if isLargeContext %}
|
|
19
|
-
Analyze the provided file list and DataSources to complete the document structure planning:
|
|
20
|
-
- If the DataSources contain sufficient context and already include content from all files in the file list, you can directly generate a detailed document structure.
|
|
21
|
-
- First plan the document structure based on DataSources and <file_list>, ensuring all user-provided information will be presented in the document
|
|
22
|
-
- Ensure initial planning has sufficient content separation to avoid oversized data sources when generating sub-documents
|
|
23
|
-
- For sections with extensive content, use the `generateSubStructure` tool to generate detailed sub-structures
|
|
24
|
-
- Trigger all Tool calls at once whenever possible
|
|
25
|
-
- When triggering Tool calls, only output Tool call related information
|
|
26
|
-
- Carefully check the data returned by the `generateSubStructure` tool, integrate all data, merge the complete document structure, and finally verify that it meets the requirements in <output_constraints>
|
|
27
|
-
|
|
28
|
-
Using `generateSubStructure`:
|
|
29
|
-
- When the provided file list is large and DataSources don't contain all file contents, resulting in an oversized context, split the generation into sub-document structures to make the context more focused and complete
|
|
30
|
-
- Generate sub-documents to more effectively and fully utilize the data source files provided in <file_list>
|
|
31
|
-
- Requires `parentDocument` and `subSourcePaths` as context parameters
|
|
32
|
-
- `subSourcePaths` supports individual files and Glob Patterns, generation process:
|
|
33
|
-
- Analyze relevant files from the file list, include as many related files as possible to ensure complete context
|
|
34
|
-
- Selected files must come from <file_list>, ensure file paths are correct
|
|
35
|
-
- Consolidation Rules:
|
|
36
|
-
1. If all files from a single directory (e.g., src/) have been selected, consolidate them into a pattern like src/\*.
|
|
37
|
-
2. If multiple files with a common naming convention are selected (e.g., README.md, README-dockerfile.md, README-turbo.md), consolidate them into a pattern like README\*.md.
|
|
38
|
-
3. Ensure only files correctly matched by the pattern are removed, while unmatched files must be preserved
|
|
39
|
-
- Merge the returned subStructure into the overall document structure plan, **ensuring all subStructures returned by the tool are included**.
|
|
40
|
-
|
|
41
|
-
{% else %}
|
|
42
|
-
The current context is sufficient, proceed directly with document structure planning based on DataSources.
|
|
43
|
-
{% endif %}
|
|
44
|
-
</sub_structure>
|
|
45
|
-
|
|
46
|
-
|
|
47
17
|
{% include "../../common/document-structure/output-constraints.md" %}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
+
<datasources>
|
|
2
|
+
Following are the partial or complete data sources provided by the user to help you design the document structure. Use these data sources to inform your structural planning.
|
|
1
3
|
|
|
2
|
-
{
|
|
3
|
-
|
|
4
|
-
{% include "../../common/document-structure/user-preferences.md" %}
|
|
5
|
-
|
|
4
|
+
{{ datasources }}
|
|
6
5
|
|
|
7
|
-
<file_list>
|
|
8
|
-
{{allFilesPaths}}
|
|
9
|
-
</file_list>
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
{{ datasources }}
|
|
7
|
+
NOTICE: There are additional data source contents not displayed. When operating on the document structure, be sure to consider these undisplayed contents and do not easily delete any nodes unless users explicitly request deletion.
|
|
13
8
|
</datasources>
|
|
14
9
|
|
|
15
10
|
{% if userContext.openAPISpec %}
|
|
@@ -17,7 +12,7 @@
|
|
|
17
12
|
|
|
18
13
|
**Goal:** Use the provided OpenAPI (Swagger) specification to design how the OpenAPI content and the overall document should be structured together.
|
|
19
14
|
|
|
20
|
-
**OpenAPI File Content:**
|
|
15
|
+
**OpenAPI File Content:**
|
|
21
16
|
<openapi_doc>
|
|
22
17
|
|
|
23
18
|
{{ userContext.openAPISpec }}
|
|
@@ -47,20 +42,31 @@
|
|
|
47
42
|
{% endif %}
|
|
48
43
|
|
|
49
44
|
|
|
50
|
-
{% if originalDocumentStructure %}
|
|
51
45
|
<last_document_structure>
|
|
52
|
-
|
|
46
|
+
projectName: |
|
|
47
|
+
{{projectName}}
|
|
48
|
+
projectDesc: |
|
|
49
|
+
{{projectDesc}}
|
|
50
|
+
|
|
51
|
+
{% if originalDocumentStructure %}
|
|
52
|
+
{{ originalDocumentStructure | yaml.stringify }}
|
|
53
|
+
{% else %}
|
|
54
|
+
No previous document structure provided. generate a new structure based on the data sources!
|
|
55
|
+
{% endif %}
|
|
56
|
+
|
|
53
57
|
</last_document_structure>
|
|
54
58
|
|
|
55
59
|
|
|
60
|
+
{% include "../../common/document-structure/user-locale-rules.md" %}
|
|
61
|
+
|
|
62
|
+
{% include "../../common/document-structure/user-preferences.md" %}
|
|
63
|
+
|
|
56
64
|
<last_document_structure_rule>
|
|
57
65
|
If a previous structural plan (last_document_structure) is provided, follow these rules:
|
|
58
66
|
1. **Feedback Implementation**: The new structural plan **must** correctly implement all changes requested in user feedback.
|
|
59
67
|
2. **Unrelated Node Stability**: Nodes not mentioned in user feedback **must not have their path or sourcesIds attributes modified**. `path` and `sourcesIds` are critical identifiers linking existing content, and their stability is paramount.
|
|
60
68
|
Ideally, other attributes (such as `title`, `description`) should also remain stable, unless these changes are directly caused by a requested modification or result from DataSource updates.
|
|
61
69
|
</last_document_structure_rule>
|
|
62
|
-
{% endif %}
|
|
63
|
-
|
|
64
70
|
|
|
65
71
|
{% if documentStructure %}
|
|
66
72
|
<review_document_structure>
|
|
@@ -92,27 +98,62 @@ Sub-structures must meet the following requirements:
|
|
|
92
98
|
- Sub-structures are planned based on DataSources and the parent document's description
|
|
93
99
|
- The parent document provides an overview of the planned content, while sub-structures directly plan the specific content to be displayed
|
|
94
100
|
- Further break down and comprehensively display the content planned in the parent document
|
|
95
|
-
- All sub-structures must have their
|
|
101
|
+
- All sub-structures must have their parentPath value set to {{parentDocument.path}}
|
|
96
102
|
</parent_document>
|
|
97
103
|
{% endif %}
|
|
98
104
|
|
|
99
105
|
<instructions>
|
|
100
|
-
Your task is to
|
|
106
|
+
Your task is to **analyze, refine, and adjust** the existing document structure (`last_document_structure`) based on the partial code repository content currently provided, generating a structural update plan.
|
|
107
|
+
You are not creating a structure from scratch, but rather **performing intelligent updates based on understanding the existing structure** to make the document structure more accurately reflect the latest code content, architectural changes, and logical relationships.
|
|
108
|
+
|
|
109
|
+
## When using <datasource> data sources, please note the following:
|
|
110
|
+
|
|
111
|
+
- Fully respect the project descriptions and usage instructions in README files, as these typically summarize the project's core functionality and objectives.
|
|
112
|
+
- Pay attention to comments and docstrings in source code files, as these reveal the design intent and usage methods of the code.
|
|
113
|
+
- Understand the relationships between various modules and files, which helps build a logically clear and well-structured document hierarchy.
|
|
114
|
+
- Notice key concepts, APIs, and configuration options in the code, as these are typically important components of the document structure.
|
|
115
|
+
- The generated document structure must include all public modules, interfaces, and features to ensure document completeness and usability.
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## Objective
|
|
119
|
+
|
|
120
|
+
Your output should be a structured change plan containing the following three sections to indicate how to modify the existing document structure:
|
|
121
|
+
|
|
122
|
+
- **add**: New structure items (array), can use index to specify insertion position (optional), each item is an object containing:
|
|
123
|
+
- `index` (optional): Insertion position index, if not specified, append to the end;
|
|
124
|
+
- `item`: New structure definition
|
|
125
|
+
- **update**: Structure items that need modification (array), each item is an object containing:
|
|
126
|
+
- `path`: Path pointing to the node being updated;
|
|
127
|
+
- `update`: New structure definition
|
|
128
|
+
|
|
129
|
+
## Behavior Rules
|
|
130
|
+
|
|
131
|
+
1. **Understanding and Inheritance**
|
|
132
|
+
- Fully understand the hierarchical logic, section divisions, and naming style in <last_document_structure>.
|
|
133
|
+
- Perform incremental updates based on this foundation, not complete rewrites.
|
|
134
|
+
- Preserve existing reasonable structures, only modify or extend when there is clear justification.
|
|
135
|
+
|
|
136
|
+
2. **Contextual Association Analysis**
|
|
137
|
+
- You will receive part of the code repository content (such as partial source files or directory content), please analyze their **documentation value and structural impact**.
|
|
138
|
+
- Identify which parts represent new concepts, APIs, modules, configurations, or features; determine if they require adding or modifying corresponding sections in the document structure.
|
|
101
139
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
- Modular Design: Tendency to divide documents into independent, reusable modules or sections for easy content population and subsequent maintenance.
|
|
107
|
-
- Flexibility and Adaptability: Ability to handle multiple types of data sources and design the most suitable documentation structure based on data source characteristics (such as code function/class structures, API endpoints/parameters, text paragraphs/themes).
|
|
108
|
-
- Clarity and Completeness: Ensure the final structural plan is easy to understand and can guide the LLM to generate a comprehensive and well-organized document.
|
|
140
|
+
3. **Structure Adjustment Strategy**
|
|
141
|
+
- If new content supplements details of existing sections, use `update`.
|
|
142
|
+
- If new content introduces new topics, modules, or hierarchies, use `add`.
|
|
143
|
+
- Ensure the position, hierarchy, and naming of new nodes align with the overall document logic.
|
|
109
144
|
|
|
145
|
+
4. **Consistency and Clarity**
|
|
146
|
+
- Ensure new or modified structure items are consistent with existing structure style.
|
|
147
|
+
- Each structure node (whether new or updated) should include:
|
|
148
|
+
- **Title**
|
|
149
|
+
- **Brief description in one sentence**, describing main content and purpose
|
|
150
|
+
- Maintain clear hierarchy, avoid duplication, ensure logical coherence. Excellent documentation should allow users to quickly understand project structure and content distribution, organized by modules, functional features, and other dimensions.
|
|
110
151
|
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
152
|
+
5. **Requirements**
|
|
153
|
+
- Follow all rules and guidelines in <document_structure_rules>.
|
|
154
|
+
- Generate rich document structure where functional modules must have sub-documents, comprehensively covering the codebase's functionality and modules, ensuring users can easily get started, understand, and use various modules and main features of the project through documentation.
|
|
114
155
|
|
|
115
156
|
{% include "../../common/document-structure/intj-traits.md" %}
|
|
116
157
|
|
|
117
|
-
|
|
158
|
+
You must make reasonable incremental modifications based solely on the new information provided while respecting the existing structure, ensuring the final structure remains complete, clear, and extensible.
|
|
118
159
|
</instructions>
|