@aigne/doc-smith 0.8.11-beta → 0.8.11-beta.2
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/.aigne/doc-smith/config.yaml +2 -0
- package/.aigne/doc-smith/output/structure-plan.json +3 -3
- package/.aigne/doc-smith/upload-cache.yaml +252 -0
- package/.github/workflows/publish-docs.yml +67 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +22 -0
- package/README.md +45 -115
- package/agents/clear/choose-contents.mjs +170 -0
- package/agents/clear/clear-auth-tokens.mjs +111 -0
- package/agents/clear/clear-document-config.mjs +39 -0
- package/agents/clear/clear-document-structure.mjs +106 -0
- package/agents/clear/clear-generated-docs.mjs +51 -0
- package/agents/clear/index.yaml +23 -0
- package/agents/evaluate/code-snippet.mjs +93 -0
- package/agents/evaluate/document-structure.yaml +70 -0
- package/agents/evaluate/document.yaml +79 -0
- package/agents/evaluate/generate-report.mjs +78 -0
- package/agents/evaluate/index.yaml +39 -0
- package/agents/generate/document-structure-tools/add-document.mjs +56 -0
- package/agents/generate/document-structure-tools/delete-document.mjs +49 -0
- package/agents/generate/document-structure-tools/move-document.mjs +82 -0
- package/agents/generate/document-structure-tools/update-document.mjs +50 -0
- package/agents/generate/generate-structure.yaml +1 -1
- package/agents/generate/update-document-structure.yaml +42 -0
- package/agents/generate/user-review-document-structure.mjs +6 -4
- package/agents/init/index.mjs +1 -1
- package/agents/publish/publish-docs.mjs +12 -3
- package/agents/translate/choose-language.mjs +1 -1
- package/agents/update/batch-update-document.yaml +7 -0
- package/agents/update/check-update-is-single.mjs +38 -0
- package/agents/update/document-tools/update-document-content.mjs +293 -0
- package/agents/update/index.yaml +4 -10
- package/agents/update/update-document-detail.yaml +52 -0
- package/agents/update/update-single-document.yaml +15 -0
- package/agents/update/user-review-document.mjs +248 -0
- package/agents/utils/choose-docs.mjs +4 -2
- package/agents/utils/format-document-structure.mjs +12 -2
- package/agents/utils/load-document-all-content.mjs +84 -0
- package/agents/utils/load-sources.mjs +4 -1
- package/aigne.yaml +59 -20
- package/assets/report-template/report.html +198 -0
- package/biome.json +14 -2
- package/docs/advanced-how-it-works.ja.md +101 -0
- package/docs/advanced-how-it-works.zh-TW.md +101 -0
- package/docs/advanced-how-it-works.zh.md +20 -20
- package/docs/advanced-quality-assurance.ja.md +96 -0
- package/docs/advanced-quality-assurance.zh-TW.md +96 -0
- package/docs/advanced-quality-assurance.zh.md +18 -18
- package/docs/advanced.ja.md +16 -0
- package/docs/advanced.zh-TW.md +16 -0
- package/docs/advanced.zh.md +4 -4
- package/docs/changelog.ja.md +309 -0
- package/docs/changelog.zh-TW.md +309 -0
- package/docs/changelog.zh.md +23 -23
- package/docs/cli-reference.ja.md +210 -0
- package/docs/cli-reference.zh-TW.md +210 -0
- package/docs/cli-reference.zh.md +21 -21
- package/docs/configuration-interactive-setup.ja.md +135 -0
- package/docs/configuration-interactive-setup.zh-TW.md +135 -0
- package/docs/configuration-interactive-setup.zh.md +29 -29
- package/docs/configuration-language-support.ja.md +94 -0
- package/docs/configuration-language-support.zh-TW.md +94 -0
- package/docs/configuration-language-support.zh.md +13 -13
- package/docs/configuration-llm-setup.ja.md +54 -0
- package/docs/configuration-llm-setup.zh-TW.md +54 -0
- package/docs/configuration-llm-setup.zh.md +12 -12
- package/docs/configuration-preferences.ja.md +129 -0
- package/docs/configuration-preferences.zh-TW.md +129 -0
- package/docs/configuration-preferences.zh.md +36 -36
- package/docs/configuration.ja.md +172 -0
- package/docs/configuration.zh-TW.md +172 -0
- package/docs/configuration.zh.md +49 -49
- package/docs/features-generate-documentation.ja.md +101 -0
- package/docs/features-generate-documentation.zh-TW.md +101 -0
- package/docs/features-generate-documentation.zh.md +17 -17
- package/docs/features-publish-your-docs.ja.md +107 -0
- package/docs/features-publish-your-docs.zh-TW.md +107 -0
- package/docs/features-publish-your-docs.zh.md +22 -22
- package/docs/features-translate-documentation.ja.md +79 -0
- package/docs/features-translate-documentation.zh-TW.md +79 -0
- package/docs/features-translate-documentation.zh.md +12 -12
- package/docs/features-update-and-refine.ja.md +138 -0
- package/docs/features-update-and-refine.zh-TW.md +138 -0
- package/docs/features-update-and-refine.zh.md +21 -21
- package/docs/features.ja.md +52 -0
- package/docs/features.zh-TW.md +52 -0
- package/docs/features.zh.md +8 -8
- package/docs/getting-started.ja.md +123 -0
- package/docs/getting-started.zh-TW.md +123 -0
- package/docs/getting-started.zh.md +24 -24
- package/docs/overview.ja.md +30 -0
- package/docs/overview.zh-TW.md +30 -0
- package/docs/overview.zh.md +8 -8
- package/package.json +19 -11
- package/prompts/common/document/content-rules-core.md +19 -0
- package/prompts/common/document/media-handling-rules.md +9 -0
- package/prompts/common/document/role-and-personality.md +15 -0
- package/prompts/common/document/user-preferences.md +9 -0
- package/prompts/common/document-structure/conflict-resolution-guidance.md +16 -0
- package/prompts/common/document-structure/document-structure-rules.md +45 -0
- package/prompts/common/document-structure/glossary.md +7 -0
- package/prompts/common/document-structure/intj-traits.md +5 -0
- package/prompts/common/document-structure/output-constraints.md +9 -0
- package/prompts/common/document-structure/user-locale-rules.md +10 -0
- package/prompts/common/document-structure/user-preferences.md +9 -0
- package/prompts/detail/custom/custom-components.md +9 -1
- package/prompts/detail/document-rules.md +6 -6
- package/prompts/detail/generate-document.md +5 -45
- package/prompts/detail/update-document.md +145 -0
- package/prompts/evaluate/document-structure.md +94 -0
- package/prompts/evaluate/document.md +149 -0
- package/prompts/structure/document-rules.md +1 -1
- package/prompts/structure/generate-structure-system.md +74 -0
- package/prompts/structure/generate-structure-user.md +41 -0
- package/prompts/structure/update-document-structure.md +118 -0
- package/prompts/translate/translate-document.md +1 -1
- package/prompts/utils/feedback-refiner.md +3 -3
- package/release-please-config.json +1 -7
- package/tests/agents/clear/choose-contents.test.mjs +280 -0
- package/tests/agents/clear/clear-auth-tokens.test.mjs +268 -0
- package/tests/agents/clear/clear-document-config.test.mjs +167 -0
- package/tests/agents/clear/clear-document-structure.test.mjs +374 -0
- package/tests/agents/clear/clear-generated-docs.test.mjs +222 -0
- package/tests/agents/evaluate/code-snippet.test.mjs +163 -0
- package/tests/agents/evaluate/fixtures/api-services.md +87 -0
- package/tests/agents/evaluate/fixtures/js-sdk.md +94 -0
- package/tests/agents/evaluate/generate-report.test.mjs +312 -0
- package/tests/agents/generate/check-document-structure.test.mjs +0 -6
- package/tests/agents/generate/document-structure-tools/add-document.test.mjs +449 -0
- package/tests/agents/generate/document-structure-tools/delete-document.test.mjs +410 -0
- package/tests/agents/generate/document-structure-tools/move-document.test.mjs +476 -0
- package/tests/agents/generate/document-structure-tools/update-document.test.mjs +548 -0
- package/tests/agents/generate/generate-structure.test.mjs +0 -6
- package/tests/agents/generate/user-review-document-structure.test.mjs +9 -9
- package/tests/agents/publish/publish-docs.test.mjs +2 -2
- package/tests/agents/update/check-update-is-single.test.mjs +300 -0
- package/tests/agents/update/document-tools/update-document-content.test.mjs +326 -0
- package/tests/agents/update/user-review-document.test.mjs +561 -0
- package/tests/agents/utils/format-document-structure.test.mjs +100 -0
- package/tests/utils/auth-utils.test.mjs +239 -1
- package/tests/utils/blocklet.test.mjs +9 -7
- package/tests/utils/constants.test.mjs +1 -1
- package/tests/utils/d2-utils.test.mjs +1 -1
- package/tests/utils/deploy.test.mjs +310 -366
- package/tests/utils/kroki-utils.test.mjs +2 -15
- package/tests/utils/linter/fixtures/css/keyword-error.css +1 -0
- package/tests/utils/linter/fixtures/css/missing-semicolon.css +1 -0
- package/tests/utils/linter/fixtures/css/syntax-error.css +1 -0
- package/tests/utils/linter/fixtures/css/undeclare-variable.css +1 -0
- package/tests/utils/linter/fixtures/css/unused-variable.css +2 -0
- package/tests/utils/linter/fixtures/css/valid-code.css +1 -0
- package/tests/utils/linter/fixtures/dockerfile/keyword-error.dockerfile +1 -0
- package/tests/utils/linter/fixtures/dockerfile/missing-semicolon.dockerfile +2 -0
- package/tests/utils/linter/fixtures/dockerfile/syntax-error.dockerfile +2 -0
- package/tests/utils/linter/fixtures/dockerfile/undeclare-variable.dockerfile +1 -0
- package/tests/utils/linter/fixtures/dockerfile/unused-variable.dockerfile +1 -0
- package/tests/utils/linter/fixtures/dockerfile/valid-code.dockerfile +2 -0
- package/tests/utils/linter/fixtures/go/keyword-error.go +5 -0
- package/tests/utils/linter/fixtures/go/missing-semicolon.go +5 -0
- package/tests/utils/linter/fixtures/go/syntax-error.go +6 -0
- package/tests/utils/linter/fixtures/go/undeclare-variable.go +5 -0
- package/tests/utils/linter/fixtures/go/unused-variable.go +5 -0
- package/tests/utils/linter/fixtures/go/valid-code.go +7 -0
- package/tests/utils/linter/fixtures/js/keyword-error.js +3 -0
- package/tests/utils/linter/fixtures/js/missing-semicolon.js +6 -0
- package/tests/utils/linter/fixtures/js/syntax-error.js +4 -0
- package/tests/utils/linter/fixtures/js/undeclare-variable.js +3 -0
- package/tests/utils/linter/fixtures/js/unused-variable.js +7 -0
- package/tests/utils/linter/fixtures/js/valid-code.js +15 -0
- package/tests/utils/linter/fixtures/json/keyword-error.json +1 -0
- package/tests/utils/linter/fixtures/json/missing-semicolon.json +1 -0
- package/tests/utils/linter/fixtures/json/syntax-error.json +1 -0
- package/tests/utils/linter/fixtures/json/undeclare-variable.json +1 -0
- package/tests/utils/linter/fixtures/json/unused-variable.json +1 -0
- package/tests/utils/linter/fixtures/json/valid-code.json +1 -0
- package/tests/utils/linter/fixtures/jsx/keyword-error.jsx +5 -0
- package/tests/utils/linter/fixtures/jsx/missing-semicolon.jsx +5 -0
- package/tests/utils/linter/fixtures/jsx/syntax-error.jsx +5 -0
- package/tests/utils/linter/fixtures/jsx/undeclare-variable.jsx +5 -0
- package/tests/utils/linter/fixtures/jsx/unused-variable.jsx +4 -0
- package/tests/utils/linter/fixtures/jsx/valid-code.jsx +5 -0
- package/tests/utils/linter/fixtures/python/keyword-error.py +3 -0
- package/tests/utils/linter/fixtures/python/missing-semicolon.py +2 -0
- package/tests/utils/linter/fixtures/python/syntax-error.py +3 -0
- package/tests/utils/linter/fixtures/python/undeclare-variable.py +3 -0
- package/tests/utils/linter/fixtures/python/unused-variable.py +6 -0
- package/tests/utils/linter/fixtures/python/valid-code.py +12 -0
- package/tests/utils/linter/fixtures/ruby/keyword-error.rb +2 -0
- package/tests/utils/linter/fixtures/ruby/missing-semicolon.rb +1 -0
- package/tests/utils/linter/fixtures/ruby/syntax-error.rb +2 -0
- package/tests/utils/linter/fixtures/ruby/undeclare-variable.rb +1 -0
- package/tests/utils/linter/fixtures/ruby/unused-variable.rb +2 -0
- package/tests/utils/linter/fixtures/ruby/valid-code.rb +1 -0
- package/tests/utils/linter/fixtures/sass/keyword-error.sass +2 -0
- package/tests/utils/linter/fixtures/sass/missing-semicolon.sass +3 -0
- package/tests/utils/linter/fixtures/sass/syntax-error.sass +3 -0
- package/tests/utils/linter/fixtures/sass/undeclare-variable.sass +2 -0
- package/tests/utils/linter/fixtures/sass/unused-variable.sass +4 -0
- package/tests/utils/linter/fixtures/sass/valid-code.sass +2 -0
- package/tests/utils/linter/fixtures/scss/keyword-error.scss +1 -0
- package/tests/utils/linter/fixtures/scss/missing-semicolon.scss +1 -0
- package/tests/utils/linter/fixtures/scss/syntax-error.scss +1 -0
- package/tests/utils/linter/fixtures/scss/undeclare-variable.scss +1 -0
- package/tests/utils/linter/fixtures/scss/unused-variable.scss +2 -0
- package/tests/utils/linter/fixtures/scss/valid-code.scss +1 -0
- package/tests/utils/linter/fixtures/shell/keyword-error.sh +5 -0
- package/tests/utils/linter/fixtures/shell/missing-semicolon.sh +3 -0
- package/tests/utils/linter/fixtures/shell/syntax-error.sh +4 -0
- package/tests/utils/linter/fixtures/shell/undeclare-variable.sh +3 -0
- package/tests/utils/linter/fixtures/shell/unused-variable.sh +4 -0
- package/tests/utils/linter/fixtures/shell/valid-code.sh +3 -0
- package/tests/utils/linter/fixtures/ts/keyword-error.ts +1 -0
- package/tests/utils/linter/fixtures/ts/missing-semicolon.ts +1 -0
- package/tests/utils/linter/fixtures/ts/syntax-error.ts +1 -0
- package/tests/utils/linter/fixtures/ts/undeclare-variable.ts +1 -0
- package/tests/utils/linter/fixtures/ts/unused-variable.ts +3 -0
- package/tests/utils/linter/fixtures/ts/valid-code.ts +3 -0
- package/tests/utils/linter/fixtures/tsx/keyword-error.tsx +5 -0
- package/tests/utils/linter/fixtures/tsx/missing-semicolon.tsx +5 -0
- package/tests/utils/linter/fixtures/tsx/syntax-error.tsx +5 -0
- package/tests/utils/linter/fixtures/tsx/undeclare-variable.tsx +6 -0
- package/tests/utils/linter/fixtures/tsx/unused-variable.tsx +6 -0
- package/tests/utils/linter/fixtures/tsx/valid-code.tsx +5 -0
- package/tests/utils/linter/fixtures/vue/keyword-error.vue +6 -0
- package/tests/utils/linter/fixtures/vue/missing-semicolon.vue +6 -0
- package/tests/utils/linter/fixtures/vue/syntax-error.vue +6 -0
- package/tests/utils/linter/fixtures/vue/undeclare-variable.vue +6 -0
- package/tests/utils/linter/fixtures/vue/unused-variable.vue +7 -0
- package/tests/utils/linter/fixtures/vue/valid-code.vue +6 -0
- package/tests/utils/linter/fixtures/yaml/keyword-error.yml +1 -0
- package/tests/utils/linter/fixtures/yaml/missing-semicolon.yml +2 -0
- package/tests/utils/linter/fixtures/yaml/syntax-error.yml +1 -0
- package/tests/utils/linter/fixtures/yaml/undeclare-variable.yml +1 -0
- package/tests/utils/linter/fixtures/yaml/unused-variable.yml +2 -0
- package/tests/utils/linter/fixtures/yaml/valid-code.yml +3 -0
- package/tests/utils/linter/index.test.mjs +440 -0
- package/tests/utils/linter/scan-results.mjs +42 -0
- package/tests/utils/markdown/index.test.mjs +478 -0
- package/tests/utils/mermaid-validator.test.mjs +2 -2
- package/tests/utils/utils.test.mjs +3 -1
- package/types/document-schema.mjs +54 -0
- package/types/document-structure-schema.mjs +244 -0
- package/utils/auth-utils.mjs +131 -6
- package/utils/conflict-detector.mjs +5 -1
- package/utils/{constants.mjs → constants/index.mjs} +109 -0
- package/utils/constants/linter.mjs +102 -0
- package/utils/d2-utils.mjs +2 -4
- package/utils/debug.mjs +3 -0
- package/utils/deploy.mjs +81 -385
- package/utils/evaluate/report-utils.mjs +131 -0
- package/utils/file-utils.mjs +36 -1
- package/utils/kroki-utils.mjs +1 -1
- package/utils/linter/index.mjs +50 -0
- package/utils/markdown/index.mjs +26 -0
- package/utils/markdown-checker.mjs +1 -1
- package/utils/utils.mjs +19 -7
- package/prompts/structure/generate-structure.md +0 -161
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type: team
|
|
2
|
+
name: updateSingleDocument
|
|
3
|
+
skills:
|
|
4
|
+
- ../update/user-review-document.mjs
|
|
5
|
+
- type: transform
|
|
6
|
+
task_render_mode: hide
|
|
7
|
+
jsonata: |
|
|
8
|
+
$merge([
|
|
9
|
+
$,
|
|
10
|
+
{ "feedback": "" }
|
|
11
|
+
])
|
|
12
|
+
- ../translate/translate-multilingual.yaml
|
|
13
|
+
- ../utils/save-single-doc.mjs
|
|
14
|
+
iterate_on: selectedDocs
|
|
15
|
+
concurrency: 1
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { marked } from "marked";
|
|
2
|
+
import markedTerminal from "marked-terminal";
|
|
3
|
+
import { getActiveRulesForScope } from "../../utils/preferences-utils.mjs";
|
|
4
|
+
|
|
5
|
+
function extractMarkdownHeadings(content) {
|
|
6
|
+
if (!content || typeof content !== "string") {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const headings = [];
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
// Use marked's lexer to tokenize the content
|
|
14
|
+
const tokens = marked.lexer(content);
|
|
15
|
+
|
|
16
|
+
// Extract heading tokens
|
|
17
|
+
function processTokens(tokenArray) {
|
|
18
|
+
for (const token of tokenArray) {
|
|
19
|
+
if (token.type === "heading") {
|
|
20
|
+
headings.push({
|
|
21
|
+
level: token.depth,
|
|
22
|
+
text: token.text.trim(),
|
|
23
|
+
prefix: " ".repeat(token.depth - 1) + "📄".repeat(1),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// Process nested tokens if they exist (for lists, block quotes, etc.)
|
|
27
|
+
if (token.tokens) {
|
|
28
|
+
processTokens(token.tokens);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
processTokens(tokens);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
// If marked fails, fall back to regex but log the issue
|
|
36
|
+
console.warn(
|
|
37
|
+
"Failed to parse markdown with marked library, falling back to regex:",
|
|
38
|
+
error.message,
|
|
39
|
+
);
|
|
40
|
+
return extractMarkdownHeadingsFallback(content);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return headings;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Fallback function using the original regex approach
|
|
47
|
+
function extractMarkdownHeadingsFallback(content) {
|
|
48
|
+
const lines = content.split("\n");
|
|
49
|
+
const headings = [];
|
|
50
|
+
|
|
51
|
+
for (const line of lines) {
|
|
52
|
+
const match = line.match(/^(#{1,6})\s+(.+)$/);
|
|
53
|
+
if (match) {
|
|
54
|
+
const level = match[1].length;
|
|
55
|
+
const text = match[2].trim();
|
|
56
|
+
headings.push({
|
|
57
|
+
level,
|
|
58
|
+
text,
|
|
59
|
+
prefix: " ".repeat(level - 1) + "📄".repeat(1),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return headings;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function printDocumentHeadings(content, title) {
|
|
68
|
+
console.log(`\n ${"-".repeat(50)}`);
|
|
69
|
+
console.log(` Current Document: ${title}`);
|
|
70
|
+
console.log(` ${"-".repeat(50)}`);
|
|
71
|
+
|
|
72
|
+
const headings = extractMarkdownHeadings(content);
|
|
73
|
+
|
|
74
|
+
if (headings.length === 0) {
|
|
75
|
+
console.log(" This document has no headings.");
|
|
76
|
+
} else {
|
|
77
|
+
headings.forEach((heading) => {
|
|
78
|
+
console.log(`${heading.prefix} ${heading.text} (H${heading.level})`);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
console.log();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function showDocumentDetail(content, title) {
|
|
85
|
+
if (!content || typeof content !== "string" || content.trim().length === 0) {
|
|
86
|
+
console.log("There's no content to display.");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
// Temporarily suppress console.error to hide language warnings
|
|
92
|
+
const originalError = console.error;
|
|
93
|
+
console.error = (message) => {
|
|
94
|
+
// Only suppress cli-highlight language warnings
|
|
95
|
+
if (
|
|
96
|
+
typeof message === "string" &&
|
|
97
|
+
message.toLowerCase().includes("Could not find the language")
|
|
98
|
+
) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
originalError(message);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
marked.setOptions({
|
|
105
|
+
renderer: new markedTerminal(),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const renderedMarkdown = marked(content);
|
|
109
|
+
|
|
110
|
+
// Restore original console.error
|
|
111
|
+
console.error = originalError;
|
|
112
|
+
|
|
113
|
+
console.log(`\nDocument: ${title || "Untitled Document"}`);
|
|
114
|
+
console.log("=".repeat(50));
|
|
115
|
+
console.log(renderedMarkdown);
|
|
116
|
+
} catch (_error) {
|
|
117
|
+
console.log("\nFalling back to plain text display (marked-terminal not available):\n");
|
|
118
|
+
console.log(`Document: ${title || "Untitled Document"}`);
|
|
119
|
+
console.log("=".repeat(50));
|
|
120
|
+
console.log(content);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export default async function userReviewDocument(
|
|
125
|
+
{ content, title, description, ...rest },
|
|
126
|
+
options,
|
|
127
|
+
) {
|
|
128
|
+
// Check if document content exists
|
|
129
|
+
if (!content || typeof content !== "string" || content.trim().length === 0) {
|
|
130
|
+
console.log("Please provide document content to review.");
|
|
131
|
+
return { content };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Print current document headings structure
|
|
135
|
+
printDocumentHeadings(content, title || "Untitled Document");
|
|
136
|
+
|
|
137
|
+
let currentContent = content;
|
|
138
|
+
|
|
139
|
+
const MAX_ITERATIONS = 100;
|
|
140
|
+
let iterationCount = 0;
|
|
141
|
+
while (iterationCount < MAX_ITERATIONS) {
|
|
142
|
+
iterationCount++;
|
|
143
|
+
|
|
144
|
+
// Ask user what they want to do
|
|
145
|
+
const action = await options.prompts.select({
|
|
146
|
+
message: "What would you like to do next?",
|
|
147
|
+
choices: [
|
|
148
|
+
{
|
|
149
|
+
name: "View document",
|
|
150
|
+
value: "view",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "Give feedback",
|
|
154
|
+
value: "feedback",
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "Done",
|
|
158
|
+
value: "finish",
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
if (action === "finish") {
|
|
164
|
+
break;
|
|
165
|
+
} else if (action === "view") {
|
|
166
|
+
await showDocumentDetail(currentContent, title || "Untitled Document");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Ask for feedback
|
|
170
|
+
const feedback = await options.prompts.input({
|
|
171
|
+
message:
|
|
172
|
+
"How would you like to improve this document?\n" +
|
|
173
|
+
" • Add, modify, or remove content\n" +
|
|
174
|
+
" • Improve clarity, accuracy, or completeness\n" +
|
|
175
|
+
" • Adjust tone, style, or technical level\n\n" +
|
|
176
|
+
" Your feedback:",
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// If no feedback, finish the loop
|
|
180
|
+
if (!feedback?.trim()) {
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Get the updateDocument agent
|
|
185
|
+
const updateAgent = options.context.agents["updateDocumentDetail"];
|
|
186
|
+
if (!updateAgent) {
|
|
187
|
+
console.log(
|
|
188
|
+
"We can't process your feedback right now. The document update feature is temporarily unavailable.",
|
|
189
|
+
);
|
|
190
|
+
console.log("Please try again later or contact support if this continues.");
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Get user preferences
|
|
195
|
+
const contentRules = getActiveRulesForScope("document", [rest.path]);
|
|
196
|
+
const globalRules = getActiveRulesForScope("global");
|
|
197
|
+
const allApplicableRules = [...contentRules, ...globalRules];
|
|
198
|
+
const ruleTexts = allApplicableRules.map((rule) => rule.rule);
|
|
199
|
+
const userPreferences = ruleTexts.length > 0 ? ruleTexts.join("\n\n") : "";
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
// Call updateDocument agent with feedback
|
|
203
|
+
const result = await options.context.invoke(updateAgent, {
|
|
204
|
+
...rest,
|
|
205
|
+
originalContent: currentContent,
|
|
206
|
+
feedback: feedback.trim(),
|
|
207
|
+
userPreferences,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
if (result.updatedContent) {
|
|
211
|
+
currentContent = result.updatedContent;
|
|
212
|
+
console.log(`\n✅ ${result.operationSummary || "Document updated successfully"}\n`);
|
|
213
|
+
} else {
|
|
214
|
+
console.log("\n❌ We couldn't update the document. Please try rephrasing your feedback.\n");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Check if feedback should be saved as user preference
|
|
218
|
+
const feedbackRefinerAgent = options.context.agents["checkFeedbackRefiner"];
|
|
219
|
+
if (feedbackRefinerAgent) {
|
|
220
|
+
try {
|
|
221
|
+
await options.context.invoke(feedbackRefinerAgent, {
|
|
222
|
+
documentContentFeedback: feedback.trim(),
|
|
223
|
+
stage: "document_refine",
|
|
224
|
+
});
|
|
225
|
+
} catch (refinerError) {
|
|
226
|
+
console.warn("We couldn't save your feedback as a preference:", refinerError.message);
|
|
227
|
+
console.warn("Your feedback was applied, but we couldn't save it as a preference.");
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Print updated document headings structure
|
|
232
|
+
printDocumentHeadings(currentContent, title || "Untitled Document");
|
|
233
|
+
} catch (error) {
|
|
234
|
+
console.error("Error processing your feedback:");
|
|
235
|
+
console.error(`Type: ${error.name}`);
|
|
236
|
+
console.error(`Message: ${error.message}`);
|
|
237
|
+
if (error.stack) {
|
|
238
|
+
console.error(`Stack: ${error.stack}`);
|
|
239
|
+
}
|
|
240
|
+
console.log("\nPlease try rephrasing your feedback or continue with the current content.");
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return { content: currentContent };
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
userReviewDocument.taskTitle = "User review and modify document content";
|
|
@@ -16,6 +16,7 @@ export default async function chooseDocs(
|
|
|
16
16
|
feedback,
|
|
17
17
|
locale,
|
|
18
18
|
reset = false,
|
|
19
|
+
requiredFeedback = true,
|
|
19
20
|
},
|
|
20
21
|
options,
|
|
21
22
|
) {
|
|
@@ -102,8 +103,9 @@ export default async function chooseDocs(
|
|
|
102
103
|
|
|
103
104
|
// Prompt for feedback if not provided
|
|
104
105
|
let userFeedback = feedback;
|
|
105
|
-
if (!userFeedback) {
|
|
106
|
-
const feedbackMessage =
|
|
106
|
+
if (!userFeedback && (requiredFeedback || foundItems?.length > 1)) {
|
|
107
|
+
const feedbackMessage =
|
|
108
|
+
"How should we improve this document? (Enter to skip, will auto-update from content sources):";
|
|
107
109
|
|
|
108
110
|
userFeedback = await options.prompts.input({
|
|
109
111
|
message: feedbackMessage,
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { stringify } from "yaml";
|
|
2
2
|
|
|
3
|
-
export default async function formatDocumentStructure({
|
|
3
|
+
export default async function formatDocumentStructure({
|
|
4
|
+
documentStructure,
|
|
5
|
+
originalDocumentStructure,
|
|
6
|
+
}) {
|
|
7
|
+
if (!documentStructure && !originalDocumentStructure) {
|
|
8
|
+
return {
|
|
9
|
+
documentStructureYaml: "",
|
|
10
|
+
documentStructure: [],
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
4
14
|
// Extract required fields from each item in documentStructure
|
|
5
|
-
const formattedData = documentStructure
|
|
15
|
+
const formattedData = (documentStructure || originalDocumentStructure)?.map((item) => ({
|
|
6
16
|
title: item.title,
|
|
7
17
|
path: item.path,
|
|
8
18
|
parentId: item.parentId,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { readdirSync } from "node:fs";
|
|
2
|
+
import { findItemByPath, readFileContent } from "../../utils/docs-finder-utils.mjs";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Loads a document's content along with all its translations from the docs directory.
|
|
6
|
+
*
|
|
7
|
+
* This function finds a document by its path in the document structure, then searches
|
|
8
|
+
* for all translation files in the docs directory that match the document's naming pattern.
|
|
9
|
+
* Translation files are identified by the pattern: {flatName}.{language-code}.md
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} params - The parameters object
|
|
12
|
+
* @param {string} params.path - The document path to find in the structure
|
|
13
|
+
* @param {string} params.docsDir - The directory containing document files and translations
|
|
14
|
+
* @param {Object} params.documentStructure - The document structure object to search in
|
|
15
|
+
* @returns {Promise<Object>} An object containing the document data with translations
|
|
16
|
+
* @throws {Error} Throws an error if the document path is not found in the structure
|
|
17
|
+
*/
|
|
18
|
+
export default async function loadDocumentAllContent({ path, docsDir, documentStructure }) {
|
|
19
|
+
// Find the document item by path in the document structure
|
|
20
|
+
const result = await findItemByPath(documentStructure, path, null, docsDir);
|
|
21
|
+
|
|
22
|
+
if (!result) {
|
|
23
|
+
throw new Error(`Document with path "${path}" not found in documentStructure`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Convert path to flat filename format (remove leading slash, replace slashes with dashes)
|
|
27
|
+
// e.g., "/api/users" becomes "api-users"
|
|
28
|
+
const flatName = result.path.replace(/^\//, "").replace(/\//g, "-");
|
|
29
|
+
|
|
30
|
+
// Arrays to store translation data in different formats
|
|
31
|
+
const translations = [];
|
|
32
|
+
const translationsString = [];
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
// Read all files in the docs directory
|
|
36
|
+
const files = readdirSync(docsDir);
|
|
37
|
+
|
|
38
|
+
// Filter files to find translation files matching the pattern:
|
|
39
|
+
// - Starts with the flat name
|
|
40
|
+
// - Ends with .md
|
|
41
|
+
// - Is not the main document file (flatName.md)
|
|
42
|
+
// - Matches language pattern: .{language-code}.md (e.g., .en.md, .zh-CN.md)
|
|
43
|
+
const translationFiles = files.filter(
|
|
44
|
+
(file) =>
|
|
45
|
+
file.startsWith(`${flatName}.`) &&
|
|
46
|
+
file.endsWith(".md") &&
|
|
47
|
+
file !== `${flatName}.md` &&
|
|
48
|
+
file.match(/\.\w+(-\w+)?\.md$/),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Process each translation file
|
|
52
|
+
for (const file of translationFiles) {
|
|
53
|
+
const content = await readFileContent(docsDir, file);
|
|
54
|
+
if (content) {
|
|
55
|
+
// Extract language code from filename (e.g., "en" from "doc.en.md" or "zh-CN" from "doc.zh-CN.md")
|
|
56
|
+
const langMatch = file.match(/\.(\w+(-\w+)?)\.md$/);
|
|
57
|
+
if (langMatch) {
|
|
58
|
+
const language = langMatch[1];
|
|
59
|
+
// Store translation in structured format
|
|
60
|
+
translations.push({
|
|
61
|
+
language,
|
|
62
|
+
translation: content,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Store translation in XML-like string format for prompt templates
|
|
66
|
+
translationsString.push(`<${language}>\n${content}\n</${language}>`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.warn(`⚠️ Could not read translation files from ${docsDir}:`, error.message);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Return the original document result enhanced with translation data
|
|
75
|
+
return {
|
|
76
|
+
...result,
|
|
77
|
+
// FIXME: @zhanghan use anthoer way to evaluate translationQuality
|
|
78
|
+
// translates: translations, // Array of translation objects with language and content
|
|
79
|
+
translationsString: translationsString.join("\n\n"), // Combined translations as formatted string
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Hide this function from task rendering in the UI
|
|
84
|
+
loadDocumentAllContent.taskRenderMode = "hide";
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { readFile, stat } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_EXCLUDE_PATTERNS,
|
|
5
|
+
DEFAULT_INCLUDE_PATTERNS,
|
|
6
|
+
} from "../../utils/constants/index.mjs";
|
|
4
7
|
import { getFilesWithGlob, loadGitignore } from "../../utils/file-utils.mjs";
|
|
5
8
|
import {
|
|
6
9
|
getCurrentGitHead,
|
package/aigne.yaml
CHANGED
|
@@ -6,41 +6,79 @@ chat_model:
|
|
|
6
6
|
# name: gemini-2.5-flash
|
|
7
7
|
temperature: 0.8
|
|
8
8
|
agents:
|
|
9
|
+
# Initialization
|
|
10
|
+
- ./agents/init/index.mjs
|
|
11
|
+
|
|
12
|
+
# Document Structure Generation
|
|
9
13
|
- ./agents/generate/generate-structure.yaml
|
|
10
|
-
- ./agents/update
|
|
11
|
-
- ./agents/utils/load-sources.mjs
|
|
12
|
-
- ./agents/utils/save-docs.mjs
|
|
13
|
-
- ./agents/translate/translate-document.yaml
|
|
14
|
-
- ./agents/update/generate-and-translate-document.yaml
|
|
15
|
-
- ./agents/update/check-document.mjs
|
|
16
|
-
- ./agents/utils/transform-detail-datasources.mjs
|
|
17
|
-
- ./agents/translate/translate-multilingual.yaml
|
|
18
|
-
- ./agents/utils/save-single-doc.mjs
|
|
19
|
-
- ./agents/utils/save-output.mjs
|
|
14
|
+
- ./agents/generate/update-document-structure.yaml
|
|
20
15
|
- ./agents/generate/check-need-generate-structure.mjs
|
|
21
|
-
- ./agents/update/generate-document.yaml
|
|
22
16
|
- ./agents/generate/refine-document-structure.yaml
|
|
23
17
|
- ./agents/generate/check-document-structure.yaml
|
|
24
|
-
- ./agents/
|
|
18
|
+
- ./agents/generate/user-review-document-structure.mjs
|
|
25
19
|
- ./agents/generate/index.yaml
|
|
20
|
+
|
|
21
|
+
# Document Structure Tools
|
|
22
|
+
- ./agents/generate/document-structure-tools/add-document.mjs
|
|
23
|
+
- ./agents/generate/document-structure-tools/delete-document.mjs
|
|
24
|
+
- ./agents/generate/document-structure-tools/update-document.mjs
|
|
25
|
+
- ./agents/generate/document-structure-tools/move-document.mjs
|
|
26
|
+
|
|
27
|
+
# Document Content Generation & Updates
|
|
28
|
+
- ./agents/update/batch-generate-document.yaml
|
|
29
|
+
- ./agents/update/generate-document.yaml
|
|
30
|
+
- ./agents/update/generate-and-translate-document.yaml
|
|
31
|
+
- ./agents/update/check-document.mjs
|
|
32
|
+
- ./agents/update/update-document-detail.yaml
|
|
33
|
+
- ./agents/update/user-review-document.mjs
|
|
34
|
+
- ./agents/update/batch-update-document.yaml
|
|
35
|
+
- ./agents/update/update-single-document.yaml
|
|
36
|
+
- ./agents/update/check-update-is-single.mjs
|
|
26
37
|
- ./agents/update/index.yaml
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Translation
|
|
41
|
+
- ./agents/translate/translate-document.yaml
|
|
42
|
+
- ./agents/translate/translate-multilingual.yaml
|
|
43
|
+
- ./agents/translate/choose-language.mjs
|
|
44
|
+
- ./agents/translate/index.yaml
|
|
45
|
+
|
|
46
|
+
# Publishing
|
|
27
47
|
- ./agents/publish/publish-docs.mjs
|
|
28
|
-
- ./agents/utils/format-document-structure.mjs
|
|
29
48
|
- ./agents/publish/index.yaml
|
|
49
|
+
|
|
50
|
+
# Clear/Cleanup
|
|
51
|
+
- ./agents/clear/choose-contents.mjs
|
|
52
|
+
- ./agents/clear/clear-document-structure.mjs
|
|
53
|
+
- ./agents/clear/clear-generated-docs.mjs
|
|
54
|
+
- ./agents/clear/clear-document-config.mjs
|
|
55
|
+
- ./agents/clear/clear-auth-tokens.mjs
|
|
56
|
+
|
|
57
|
+
# Utilities
|
|
58
|
+
- ./agents/utils/load-sources.mjs
|
|
59
|
+
- ./agents/utils/save-docs.mjs
|
|
60
|
+
- ./agents/utils/transform-detail-datasources.mjs
|
|
61
|
+
- ./agents/utils/save-single-doc.mjs
|
|
62
|
+
- ./agents/utils/save-output.mjs
|
|
63
|
+
- ./agents/utils/format-document-structure.mjs
|
|
30
64
|
- ./agents/utils/find-item-by-path.mjs
|
|
31
|
-
- ./agents/
|
|
32
|
-
- ./agents/
|
|
65
|
+
- ./agents/utils/check-feedback-refiner.mjs
|
|
66
|
+
- ./agents/utils/feedback-refiner.yaml
|
|
67
|
+
|
|
68
|
+
# User Preferences & Chat
|
|
69
|
+
- ./agents/prefs/index.mjs
|
|
70
|
+
- ./agents/chat/index.yaml
|
|
71
|
+
|
|
72
|
+
# Documentation MCP Server
|
|
33
73
|
- ./docs-mcp/get-docs-structure.mjs
|
|
34
74
|
- ./docs-mcp/get-docs-detail.mjs
|
|
35
75
|
- ./docs-mcp/docs-search.yaml
|
|
36
76
|
- ./docs-mcp/analyze-docs-relevance.yaml
|
|
37
77
|
- ./docs-mcp/read-doc-content.mjs
|
|
38
78
|
- ./docs-mcp/analyze-content-relevance.yaml
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
- ./agents/
|
|
42
|
-
- ./agents/chat/index.yaml
|
|
43
|
-
- ./agents/generate/user-review-document-structure.mjs
|
|
79
|
+
|
|
80
|
+
# Evaluation
|
|
81
|
+
- ./agents/evaluate/index.yaml
|
|
44
82
|
cli:
|
|
45
83
|
chat: ./agents/chat/index.yaml
|
|
46
84
|
agents:
|
|
@@ -49,6 +87,7 @@ cli:
|
|
|
49
87
|
- ./agents/update/index.yaml
|
|
50
88
|
- ./agents/publish/index.yaml
|
|
51
89
|
- ./agents/translate/index.yaml
|
|
90
|
+
- ./agents/clear/index.yaml
|
|
52
91
|
- ./agents/prefs/index.mjs
|
|
53
92
|
mcp_server:
|
|
54
93
|
agents:
|