@aigne/doc-smith 0.8.11-beta.4 → 0.8.11-beta.6
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 -4
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +17 -2
- package/README.md +1 -1
- package/agents/clear/choose-contents.mjs +2 -2
- package/agents/clear/clear-document-structure.mjs +8 -8
- package/agents/clear/index.yaml +1 -1
- package/agents/evaluate/document-structure.yaml +1 -1
- package/agents/generate/check-d2-diagram-valid.mjs +26 -0
- package/agents/generate/check-document-structure.yaml +3 -3
- package/agents/generate/check-need-generate-structure.mjs +8 -8
- package/agents/generate/document-structure-tools/add-document.mjs +3 -3
- package/agents/generate/document-structure-tools/delete-document.mjs +2 -2
- package/agents/generate/document-structure-tools/move-document.mjs +3 -2
- package/agents/generate/document-structure-tools/update-document.mjs +2 -2
- package/agents/generate/generate-d2-diagram.yaml +23 -0
- package/agents/generate/generate-structure.yaml +1 -1
- package/agents/generate/merge-d2-diagram.yaml +39 -0
- package/agents/generate/update-document-structure.yaml +3 -3
- package/agents/generate/user-review-document-structure.mjs +10 -10
- package/agents/init/index.mjs +18 -10
- package/agents/publish/publish-docs.mjs +17 -20
- package/agents/update/batch-generate-document.yaml +1 -1
- package/agents/update/check-document.mjs +2 -2
- package/agents/update/generate-document.yaml +25 -0
- package/agents/utils/check-feedback-refiner.mjs +1 -1
- package/agents/utils/choose-docs.mjs +1 -1
- package/agents/utils/load-document-all-content.mjs +3 -3
- package/agents/utils/load-sources.mjs +1 -1
- package/agents/utils/save-docs.mjs +7 -28
- package/aigne.yaml +2 -2
- package/docs/_sidebar.md +1 -1
- package/docs/advanced-how-it-works.md +3 -3
- package/docs/advanced-quality-assurance.md +1 -1
- package/docs/cli-reference.ja.md +151 -80
- package/docs/cli-reference.md +126 -55
- package/docs/cli-reference.zh-TW.md +133 -62
- package/docs/cli-reference.zh.md +143 -72
- package/docs/configuration-interactive-setup.md +1 -1
- package/docs/configuration-language-support.md +1 -1
- package/docs/configuration-preferences.md +1 -1
- package/docs/configuration.ja.md +104 -48
- package/docs/configuration.md +58 -2
- package/docs/configuration.zh-TW.md +99 -42
- package/docs/configuration.zh.md +78 -21
- package/docs/features-generate-documentation.ja.md +63 -44
- package/docs/features-generate-documentation.md +54 -35
- package/docs/features-generate-documentation.zh-TW.md +67 -48
- package/docs/features-generate-documentation.zh.md +61 -41
- package/docs/features-publish-your-docs.ja.md +69 -46
- package/docs/features-publish-your-docs.md +65 -42
- package/docs/features-publish-your-docs.zh-TW.md +73 -50
- package/docs/features-publish-your-docs.zh.md +67 -44
- package/docs/features-translate-documentation.ja.md +35 -33
- package/docs/features-translate-documentation.md +24 -22
- package/docs/features-translate-documentation.zh-TW.md +32 -30
- package/docs/features-translate-documentation.zh.md +29 -27
- package/docs/features-update-and-refine.ja.md +120 -66
- package/docs/features-update-and-refine.md +110 -56
- package/docs/features-update-and-refine.zh-TW.md +116 -62
- package/docs/features-update-and-refine.zh.md +118 -64
- package/docs/getting-started.ja.md +22 -22
- package/docs/getting-started.md +1 -1
- package/docs/getting-started.zh-TW.md +16 -16
- package/docs/getting-started.zh.md +28 -28
- package/docs/overview.md +3 -3
- package/docs-mcp/analyze-docs-relevance.yaml +6 -6
- package/docs-mcp/docs-search.yaml +1 -1
- package/package.json +3 -3
- package/prompts/common/document-structure/conflict-resolution-guidance.md +3 -3
- package/prompts/common/document-structure/document-structure-rules.md +2 -2
- package/prompts/detail/{d2-chart/rules.md → d2-diagram/rules-system.md} +41 -5
- package/prompts/detail/d2-diagram/rules-user.md +4 -0
- package/prompts/detail/document-rules.md +3 -4
- package/prompts/detail/generate-document.md +8 -2
- package/prompts/detail/update-document.md +0 -2
- package/prompts/evaluate/document-structure.md +6 -6
- package/prompts/structure/check-document-structure.md +10 -10
- package/prompts/structure/document-rules.md +2 -2
- package/prompts/structure/generate-structure-system.md +3 -3
- package/prompts/structure/structure-example.md +1 -1
- package/prompts/structure/structure-getting-started.md +1 -1
- package/prompts/structure/update-document-structure.md +9 -9
- package/prompts/utils/feedback-refiner.md +1 -1
- package/tests/agents/clear/choose-contents.test.mjs +1 -1
- package/tests/agents/clear/clear-document-structure.test.mjs +36 -30
- package/tests/agents/evaluate/generate-report.test.mjs +1 -1
- package/tests/agents/generate/check-need-generate-structure.test.mjs +1 -1
- package/tests/agents/generate/document-structure-tools/add-document.test.mjs +2 -2
- package/tests/agents/generate/document-structure-tools/delete-document.test.mjs +4 -4
- package/tests/agents/generate/document-structure-tools/move-document.test.mjs +3 -3
- package/tests/agents/generate/document-structure-tools/update-document.test.mjs +3 -3
- package/tests/agents/generate/user-review-document-structure.test.mjs +7 -5
- package/tests/agents/init/init.test.mjs +25 -19
- package/tests/agents/publish/publish-docs.test.mjs +99 -0
- package/tests/agents/update/check-document.test.mjs +1 -1
- package/tests/agents/utils/check-detail-result.test.mjs +2 -15
- package/tests/agents/utils/format-document-structure.test.mjs +5 -5
- package/tests/agents/utils/load-sources.test.mjs +4 -4
- package/tests/agents/utils/save-docs.test.mjs +1 -1
- package/tests/utils/auth-utils.test.mjs +1 -1
- package/tests/utils/conflict-detector.test.mjs +1 -1
- package/tests/utils/d2-utils.test.mjs +4 -4
- package/tests/utils/deploy.test.mjs +3 -10
- package/tests/utils/docs-finder-utils.test.mjs +8 -8
- package/tests/utils/kroki-utils.test.mjs +5 -5
- package/tests/utils/preferences-utils.test.mjs +5 -3
- package/tests/utils/save-value-to-config.test.mjs +3 -1
- package/types/document-structure-schema.mjs +9 -9
- package/utils/auth-utils.mjs +4 -0
- package/utils/conflict-detector.mjs +1 -1
- package/utils/constants/index.mjs +7 -4
- package/utils/d2-utils.mjs +11 -6
- package/utils/deploy.mjs +4 -20
- package/utils/docs-finder-utils.mjs +11 -11
- package/utils/kroki-utils.mjs +5 -4
- package/utils/markdown-checker.mjs +1 -21
- /package/prompts/detail/{d2-chart → d2-diagram}/official-examples.md +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<getting_started_document_structure_rules>
|
|
2
|
-
Based on the provided data sources, plan a Getting Started
|
|
2
|
+
Based on the provided data sources, plan a Getting Started documentation structure:
|
|
3
3
|
- The entire structure should be complete and continuous, allowing users to follow the documentation step by step to complete a working example
|
|
4
4
|
- Each document section should complete a relatively complete step, avoiding overly long individual sections that create reading pressure for users
|
|
5
5
|
- Provide reference command lines and code as needed to facilitate users following the documentation
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<role_and_goal>
|
|
2
2
|
|
|
3
|
-
You are a
|
|
4
|
-
You analyze user feedback and intentions to modify existing
|
|
3
|
+
You are a documentation structure update specialist with the strategic mindset of an **INTJ** (The Architect).
|
|
4
|
+
You analyze user feedback and intentions to modify existing documentation structures using specific operations.
|
|
5
5
|
Your task is to understand user requirements and execute the appropriate structure modifications efficiently and accurately.
|
|
6
6
|
|
|
7
7
|
{% include "../common/document-structure/intj-traits.md" %}
|
|
@@ -12,15 +12,15 @@ Processing workflow:
|
|
|
12
12
|
- Analyze user feedback to understand the specific intent (add, delete, update, or move sections)
|
|
13
13
|
- Determine which tools to use based on the user's requirements
|
|
14
14
|
- Execute the appropriate operations using available tools
|
|
15
|
-
- Ensure all modifications maintain
|
|
15
|
+
- Ensure all modifications maintain documentation structure integrity
|
|
16
16
|
|
|
17
17
|
Rules:
|
|
18
|
-
** Never generate new
|
|
19
|
-
** Use the
|
|
18
|
+
** Never generate new documentation structures directly. All changes must be made using Tools. **
|
|
19
|
+
** Use the documentation structure returned by Tools as the latest version, check if it satisfies the user's feedback, and if so, return the latest version directly. **
|
|
20
20
|
|
|
21
21
|
Objectives:
|
|
22
|
-
-
|
|
23
|
-
- Each {{nodeName}} should include: {{nodeName}} title, a one-sentence introduction
|
|
22
|
+
- Create a clear and logical structural plan that comprehensively presents information from the user-provided context while providing users with intuitive navigation paths.
|
|
23
|
+
- Each {{nodeName}} should include: a {{nodeName}} title, a one-sentence introduction describing its main content, with presentation and organization methods tailored to the target audience.
|
|
24
24
|
|
|
25
25
|
</role_and_goal>
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ Objectives:
|
|
|
28
28
|
|
|
29
29
|
{% include "../common/document-structure/user-preferences.md" %}
|
|
30
30
|
|
|
31
|
-
Initial
|
|
31
|
+
Initial Documentation Structure:
|
|
32
32
|
<initial_document_structure>
|
|
33
33
|
{{documentStructure}}
|
|
34
34
|
</initial_document_structure>
|
|
@@ -87,7 +87,7 @@ Operation execution rules:
|
|
|
87
87
|
- **Use only the appropriate tools** based on the determined operation type
|
|
88
88
|
- **Validate all required parameters** before calling tools
|
|
89
89
|
- **Maintain data integrity** by ensuring all constraints are met
|
|
90
|
-
- **Only use Tools to update data** Use provided Tools to modify
|
|
90
|
+
- **Only use Tools to update data** Use provided Tools to modify documentation structure, use the documentation structure returned by Tools as the latest version
|
|
91
91
|
- **Use Tool return results** When all Tool calls are complete, directly use the result from the last Tool
|
|
92
92
|
|
|
93
93
|
Tool usage guidelines:
|
|
@@ -33,7 +33,7 @@ Save determination rules:
|
|
|
33
33
|
**One-time operations (do not save)**:
|
|
34
34
|
- Only corrects current version/typos/individual phrasing/local factual errors with no stable reusable value → `save=false`
|
|
35
35
|
- Fixes that are highly specific to a single line or data point and unlikely to recur (e.g., "change the year from 2020 to 2021") → `save=false`
|
|
36
|
-
-
|
|
36
|
+
- Documentation Structure adjustments, adding new documents, and moving document positions are always one-time operations → `save=false`
|
|
37
37
|
|
|
38
38
|
**Reusable policies (save)**:
|
|
39
39
|
- Writing styles, structural conventions, inclusion/exclusion items, translation conventions that are broadly applicable and should be consistently executed in the future → `save=true`
|
|
@@ -15,7 +15,7 @@ describe("choose-contents", () => {
|
|
|
15
15
|
path: "/test/docs",
|
|
16
16
|
})),
|
|
17
17
|
clearDocumentStructure: mock(async () => ({
|
|
18
|
-
message: "
|
|
18
|
+
message: "Documentation Structure cleared",
|
|
19
19
|
cleared: true,
|
|
20
20
|
path: "/test/structure.json",
|
|
21
21
|
})),
|
|
@@ -34,8 +34,8 @@ describe("clear-document-structure", () => {
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
test("should clear structure
|
|
38
|
-
// Create a test structure
|
|
37
|
+
test("should clear documentation structure only when no docsDir provided", async () => {
|
|
38
|
+
// Create a test documentation structure file
|
|
39
39
|
const structurePlan = {
|
|
40
40
|
documents: [
|
|
41
41
|
{ path: "/intro", title: "Introduction" },
|
|
@@ -46,18 +46,18 @@ describe("clear-document-structure", () => {
|
|
|
46
46
|
|
|
47
47
|
const result = await clearDocumentStructure({ workDir: testDir });
|
|
48
48
|
|
|
49
|
-
expect(result.message).toContain("
|
|
49
|
+
expect(result.message).toContain("Documentation Structure cleared successfully!");
|
|
50
50
|
expect(result.hasError).toBe(false);
|
|
51
51
|
expect(result.clearedCount).toBe(1);
|
|
52
52
|
|
|
53
|
-
// Verify structure
|
|
53
|
+
// Verify documentation structure file is actually deleted
|
|
54
54
|
const { pathExists } = await import("../../../utils/file-utils.mjs");
|
|
55
55
|
const exists = await pathExists(structurePlanPath);
|
|
56
56
|
expect(exists).toBe(false);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
test("should clear both structure
|
|
60
|
-
// Create structure
|
|
59
|
+
test("should clear both documentation structure and docs directory when docsDir provided", async () => {
|
|
60
|
+
// Create documentation structure
|
|
61
61
|
await writeFile(structurePlanPath, JSON.stringify({ test: "data" }));
|
|
62
62
|
|
|
63
63
|
// Create docs directory with files
|
|
@@ -67,7 +67,7 @@ describe("clear-document-structure", () => {
|
|
|
67
67
|
|
|
68
68
|
const result = await clearDocumentStructure({ workDir: testDir, docsDir });
|
|
69
69
|
|
|
70
|
-
expect(result.message).toContain("
|
|
70
|
+
expect(result.message).toContain("Documentation Structure cleared successfully!");
|
|
71
71
|
expect(result.clearedCount).toBe(2);
|
|
72
72
|
|
|
73
73
|
// Verify both are deleted
|
|
@@ -78,17 +78,17 @@ describe("clear-document-structure", () => {
|
|
|
78
78
|
expect(docsExists).toBe(false);
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
test("should handle non-existent structure
|
|
82
|
-
// Don't create the structure
|
|
81
|
+
test("should handle non-existent documentation structure file", async () => {
|
|
82
|
+
// Don't create the documentation structure file
|
|
83
83
|
const result = await clearDocumentStructure({ workDir: testDir });
|
|
84
84
|
|
|
85
|
-
expect(result.message).toContain("
|
|
85
|
+
expect(result.message).toContain("Documentation Structure already empty.");
|
|
86
86
|
expect(result.clearedCount).toBe(0);
|
|
87
87
|
expect(result.hasError).toBe(false);
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
test("should handle non-existent docs directory", async () => {
|
|
91
|
-
// Create structure
|
|
91
|
+
// Create documentation structure but not docs directory
|
|
92
92
|
await writeFile(structurePlanPath, JSON.stringify({ test: "data" }));
|
|
93
93
|
|
|
94
94
|
const nonExistentDocsDir = join(testDir, "non-existent-docs");
|
|
@@ -98,10 +98,10 @@ describe("clear-document-structure", () => {
|
|
|
98
98
|
docsDir: nonExistentDocsDir,
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
expect(result.message).toContain("
|
|
102
|
-
expect(result.clearedCount).toBe(1); // Only structure
|
|
101
|
+
expect(result.message).toContain("Documentation Structure cleared successfully!");
|
|
102
|
+
expect(result.clearedCount).toBe(1); // Only documentation structure cleared
|
|
103
103
|
|
|
104
|
-
// Verify structure
|
|
104
|
+
// Verify documentation structure is deleted
|
|
105
105
|
const { pathExists } = await import("../../../utils/file-utils.mjs");
|
|
106
106
|
const exists = await pathExists(structurePlanPath);
|
|
107
107
|
expect(exists).toBe(false);
|
|
@@ -114,12 +114,12 @@ describe("clear-document-structure", () => {
|
|
|
114
114
|
// Change to test directory
|
|
115
115
|
process.chdir(testDir);
|
|
116
116
|
|
|
117
|
-
// Create structure
|
|
117
|
+
// Create documentation structure in current directory's structure
|
|
118
118
|
await writeFile(structurePlanPath, JSON.stringify({ test: "data" }));
|
|
119
119
|
|
|
120
120
|
const result = await clearDocumentStructure({});
|
|
121
121
|
|
|
122
|
-
expect(result.message).toContain("
|
|
122
|
+
expect(result.message).toContain("Documentation Structure cleared successfully!");
|
|
123
123
|
expect(result.clearedCount).toBe(1);
|
|
124
124
|
} finally {
|
|
125
125
|
// Restore original working directory
|
|
@@ -159,15 +159,15 @@ describe("clear-document-structure", () => {
|
|
|
159
159
|
|
|
160
160
|
test("should have correct task metadata", () => {
|
|
161
161
|
expect(clearDocumentStructure.taskTitle).toBe(
|
|
162
|
-
"Clear
|
|
162
|
+
"Clear documentation structure and all generated documents",
|
|
163
163
|
);
|
|
164
164
|
expect(clearDocumentStructure.description).toBe(
|
|
165
|
-
"Clear the
|
|
165
|
+
"Clear the documentation structure (structure-plan.json) and optionally the documents directory",
|
|
166
166
|
);
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
-
test("should handle complex
|
|
170
|
-
// Create complex structure
|
|
169
|
+
test("should handle complex documentation structures", async () => {
|
|
170
|
+
// Create complex documentation structure
|
|
171
171
|
const complexStructure = {
|
|
172
172
|
documents: [
|
|
173
173
|
{
|
|
@@ -289,7 +289,7 @@ describe("clear-document-structure", () => {
|
|
|
289
289
|
const structureResult = result.results.find((r) => r.type === "structure");
|
|
290
290
|
expect(structureResult).toBeDefined();
|
|
291
291
|
expect(structureResult.cleared).toBe(true);
|
|
292
|
-
expect(structureResult.message).toContain("structure
|
|
292
|
+
expect(structureResult.message).toContain("documentation structure");
|
|
293
293
|
|
|
294
294
|
// Check documents result
|
|
295
295
|
const docsResult = result.results.find((r) => r.type === "documents");
|
|
@@ -298,12 +298,12 @@ describe("clear-document-structure", () => {
|
|
|
298
298
|
expect(docsResult.message).toContain("documents directory");
|
|
299
299
|
});
|
|
300
300
|
|
|
301
|
-
test("should handle structure
|
|
302
|
-
// Create a spy on rm to simulate an error for structure
|
|
301
|
+
test("should handle documentation structure file removal errors", async () => {
|
|
302
|
+
// Create a spy on rm to simulate an error for documentation structure
|
|
303
303
|
const rmSpy = spyOn(fsPromises, "rm");
|
|
304
304
|
rmSpy.mockImplementation((path, _options) => {
|
|
305
305
|
if (path.includes("structure-plan.json")) {
|
|
306
|
-
throw new Error("Permission denied for structure
|
|
306
|
+
throw new Error("Permission denied for documentation structure");
|
|
307
307
|
}
|
|
308
308
|
return Promise.resolve();
|
|
309
309
|
});
|
|
@@ -312,19 +312,21 @@ describe("clear-document-structure", () => {
|
|
|
312
312
|
const result = await clearDocumentStructure({ workDir: testDir });
|
|
313
313
|
|
|
314
314
|
expect(result.hasError).toBe(true);
|
|
315
|
-
expect(result.message).toContain(
|
|
315
|
+
expect(result.message).toContain(
|
|
316
|
+
"Documentation Structure cleanup finished with some issues.",
|
|
317
|
+
);
|
|
316
318
|
|
|
317
319
|
const structureResult = result.results.find((r) => r.type === "structure");
|
|
318
320
|
expect(structureResult.error).toBe(true);
|
|
319
|
-
expect(structureResult.message).toContain("Failed to clear
|
|
320
|
-
expect(structureResult.message).toContain("Permission denied for structure
|
|
321
|
+
expect(structureResult.message).toContain("Failed to clear documentation structure");
|
|
322
|
+
expect(structureResult.message).toContain("Permission denied for documentation structure");
|
|
321
323
|
} finally {
|
|
322
324
|
rmSpy.mockRestore();
|
|
323
325
|
}
|
|
324
326
|
});
|
|
325
327
|
|
|
326
328
|
test("should handle documents directory removal errors", async () => {
|
|
327
|
-
// Create structure
|
|
329
|
+
// Create documentation structure file
|
|
328
330
|
await writeFile(structurePlanPath, JSON.stringify({ test: "data" }));
|
|
329
331
|
|
|
330
332
|
// Create a spy on rm to simulate an error for docs directory
|
|
@@ -340,7 +342,9 @@ describe("clear-document-structure", () => {
|
|
|
340
342
|
const result = await clearDocumentStructure({ workDir: testDir, docsDir });
|
|
341
343
|
|
|
342
344
|
expect(result.hasError).toBe(true);
|
|
343
|
-
expect(result.message).toContain(
|
|
345
|
+
expect(result.message).toContain(
|
|
346
|
+
"Documentation Structure cleanup finished with some issues.",
|
|
347
|
+
);
|
|
344
348
|
|
|
345
349
|
const docsResult = result.results.find((r) => r.type === "documents");
|
|
346
350
|
expect(docsResult.error).toBe(true);
|
|
@@ -362,7 +366,9 @@ describe("clear-document-structure", () => {
|
|
|
362
366
|
const result = await clearDocumentStructure({ workDir: testDir, docsDir });
|
|
363
367
|
|
|
364
368
|
expect(result.hasError).toBe(true);
|
|
365
|
-
expect(result.message).toContain(
|
|
369
|
+
expect(result.message).toContain(
|
|
370
|
+
"Documentation Structure cleanup finished with some issues.",
|
|
371
|
+
);
|
|
366
372
|
expect(result.results).toHaveLength(2);
|
|
367
373
|
|
|
368
374
|
// Both operations should have errors
|
|
@@ -189,7 +189,7 @@ describe("generateEvaluationReport", () => {
|
|
|
189
189
|
expect(firstDoc.codeEvaluation).toBe(null);
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
test("should handle empty
|
|
192
|
+
test("should handle empty documentation structure", async () => {
|
|
193
193
|
const testData = {
|
|
194
194
|
structureEvaluation: {
|
|
195
195
|
purposeCoverage: {
|
|
@@ -87,7 +87,7 @@ describe("check-need-generate-structure", () => {
|
|
|
87
87
|
saveValueToConfigSpy?.mockRestore();
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
test("should return original
|
|
90
|
+
test("should return original documentation structure when no regeneration needed", async () => {
|
|
91
91
|
// Test when no feedback and no sidebar file exists (default mock behavior)
|
|
92
92
|
const result = await checkNeedGenerateStructure(
|
|
93
93
|
{ originalDocumentStructure, docsDir: "./docs" },
|
|
@@ -335,7 +335,7 @@ describe("add-document", () => {
|
|
|
335
335
|
});
|
|
336
336
|
|
|
337
337
|
// EDGE CASES
|
|
338
|
-
test("should handle empty
|
|
338
|
+
test("should handle empty documentation structure", async () => {
|
|
339
339
|
const result = await addDocument({
|
|
340
340
|
documentStructure: [],
|
|
341
341
|
title: "First Document",
|
|
@@ -418,7 +418,7 @@ describe("add-document", () => {
|
|
|
418
418
|
});
|
|
419
419
|
|
|
420
420
|
// DATA INTEGRITY TESTS
|
|
421
|
-
test("should not modify original
|
|
421
|
+
test("should not modify original documentation structure", async () => {
|
|
422
422
|
const originalStructure = [...baseDocumentStructure];
|
|
423
423
|
|
|
424
424
|
await addDocument({
|
|
@@ -197,7 +197,7 @@ describe("delete-document", () => {
|
|
|
197
197
|
});
|
|
198
198
|
|
|
199
199
|
// EDGE CASES
|
|
200
|
-
test("should handle empty
|
|
200
|
+
test("should handle empty documentation structure", async () => {
|
|
201
201
|
const result = await deleteDocument({
|
|
202
202
|
documentStructure: [],
|
|
203
203
|
path: "/any-path",
|
|
@@ -210,7 +210,7 @@ describe("delete-document", () => {
|
|
|
210
210
|
);
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
-
test("should handle
|
|
213
|
+
test("should handle documentation structure with single document", async () => {
|
|
214
214
|
const singleDocStructure = [
|
|
215
215
|
{
|
|
216
216
|
title: "Only Document",
|
|
@@ -313,7 +313,7 @@ describe("delete-document", () => {
|
|
|
313
313
|
});
|
|
314
314
|
|
|
315
315
|
// DATA INTEGRITY TESTS
|
|
316
|
-
test("should not modify original
|
|
316
|
+
test("should not modify original documentation structure", async () => {
|
|
317
317
|
const originalStructure = [...baseDocumentStructure];
|
|
318
318
|
|
|
319
319
|
await deleteDocument({
|
|
@@ -390,7 +390,7 @@ describe("delete-document", () => {
|
|
|
390
390
|
expect(result.deletedDocument).toHaveProperty("sourceIds");
|
|
391
391
|
});
|
|
392
392
|
|
|
393
|
-
test("should return updated
|
|
393
|
+
test("should return updated documentation structure without deleted document", async () => {
|
|
394
394
|
const originalLength = baseDocumentStructure.length;
|
|
395
395
|
const result = await deleteDocument({
|
|
396
396
|
documentStructure: baseDocumentStructure,
|
|
@@ -326,7 +326,7 @@ describe("move-document", () => {
|
|
|
326
326
|
expect(updatedDoc.parentId).not.toBe(originalDoc.parentId);
|
|
327
327
|
});
|
|
328
328
|
|
|
329
|
-
test("should handle empty
|
|
329
|
+
test("should handle empty documentation structure", async () => {
|
|
330
330
|
const result = await moveDocument({
|
|
331
331
|
documentStructure: [],
|
|
332
332
|
path: "/any-path",
|
|
@@ -339,7 +339,7 @@ describe("move-document", () => {
|
|
|
339
339
|
);
|
|
340
340
|
});
|
|
341
341
|
|
|
342
|
-
test("should handle single
|
|
342
|
+
test("should handle single documentation structure", async () => {
|
|
343
343
|
const singleDocStructure = [
|
|
344
344
|
{
|
|
345
345
|
title: "Only Document",
|
|
@@ -363,7 +363,7 @@ describe("move-document", () => {
|
|
|
363
363
|
});
|
|
364
364
|
|
|
365
365
|
// DATA INTEGRITY TESTS
|
|
366
|
-
test("should not modify original
|
|
366
|
+
test("should not modify original documentation structure", async () => {
|
|
367
367
|
const originalStructure = [...baseDocumentStructure];
|
|
368
368
|
|
|
369
369
|
await moveDocument({
|
|
@@ -319,7 +319,7 @@ describe("update-document", () => {
|
|
|
319
319
|
expect(consoleSpy).not.toHaveBeenCalled();
|
|
320
320
|
});
|
|
321
321
|
|
|
322
|
-
test("should handle empty
|
|
322
|
+
test("should handle empty documentation structure", async () => {
|
|
323
323
|
const result = await updateDocument({
|
|
324
324
|
documentStructure: [],
|
|
325
325
|
path: "/any-path",
|
|
@@ -332,7 +332,7 @@ describe("update-document", () => {
|
|
|
332
332
|
);
|
|
333
333
|
});
|
|
334
334
|
|
|
335
|
-
test("should handle single
|
|
335
|
+
test("should handle single documentation structure", async () => {
|
|
336
336
|
const singleDocStructure = [
|
|
337
337
|
{
|
|
338
338
|
title: "Only Document",
|
|
@@ -377,7 +377,7 @@ describe("update-document", () => {
|
|
|
377
377
|
});
|
|
378
378
|
|
|
379
379
|
// DATA INTEGRITY TESTS
|
|
380
|
-
test("should not modify original
|
|
380
|
+
test("should not modify original documentation structure", async () => {
|
|
381
381
|
const originalStructure = [...baseDocumentStructure];
|
|
382
382
|
|
|
383
383
|
await updateDocument({
|
|
@@ -71,13 +71,13 @@ describe("user-review-document-structure", () => {
|
|
|
71
71
|
consoleSpy?.mockRestore();
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
test("should return original structure when no
|
|
74
|
+
test("should return original structure when no documentation structure provided", async () => {
|
|
75
75
|
const result = await userReviewDocumentStructure({}, mockOptions);
|
|
76
76
|
|
|
77
77
|
expect(result).toBeDefined();
|
|
78
78
|
expect(result.documentStructure).toBeUndefined();
|
|
79
79
|
expect(mockOptions.prompts.select).not.toHaveBeenCalled();
|
|
80
|
-
expect(consoleSpy).toHaveBeenCalledWith("No
|
|
80
|
+
expect(consoleSpy).toHaveBeenCalledWith("No documentation structure was generated to review.");
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
test("should return original structure when empty array provided", async () => {
|
|
@@ -86,7 +86,7 @@ describe("user-review-document-structure", () => {
|
|
|
86
86
|
expect(result).toBeDefined();
|
|
87
87
|
expect(result.documentStructure).toEqual([]);
|
|
88
88
|
expect(mockOptions.prompts.select).not.toHaveBeenCalled();
|
|
89
|
-
expect(consoleSpy).toHaveBeenCalledWith("No
|
|
89
|
+
expect(consoleSpy).toHaveBeenCalledWith("No documentation structure was generated to review.");
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
test("should return original structure when user chooses not to review", async () => {
|
|
@@ -110,7 +110,9 @@ describe("user-review-document-structure", () => {
|
|
|
110
110
|
expect(result.documentStructure).toEqual(documentStructure);
|
|
111
111
|
expect(mockOptions.prompts.select).toHaveBeenCalled();
|
|
112
112
|
expect(mockOptions.prompts.input).toHaveBeenCalled();
|
|
113
|
-
expect(consoleSpy).toHaveBeenCalledWith(
|
|
113
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
114
|
+
expect.stringContaining("Current Documentation Structure"),
|
|
115
|
+
);
|
|
114
116
|
});
|
|
115
117
|
|
|
116
118
|
test("should process user feedback and call refineDocumentStructure agent", async () => {
|
|
@@ -188,7 +190,7 @@ describe("user-review-document-structure", () => {
|
|
|
188
190
|
|
|
189
191
|
expect(result.documentStructure).toEqual(documentStructure);
|
|
190
192
|
expect(consoleSpy).toHaveBeenCalledWith(
|
|
191
|
-
"Unable to process your feedback - the
|
|
193
|
+
"Unable to process your feedback - the documentation structure update feature is unavailable.",
|
|
192
194
|
);
|
|
193
195
|
});
|
|
194
196
|
|
|
@@ -986,11 +986,12 @@ describe("init", () => {
|
|
|
986
986
|
const mockResponses = {
|
|
987
987
|
checkbox_1: ["getStarted", "findAnswers"], // Document purpose
|
|
988
988
|
checkbox_2: ["developers"], // Target audience
|
|
989
|
-
|
|
990
|
-
select_4: "
|
|
991
|
-
select_5: "
|
|
992
|
-
|
|
993
|
-
|
|
989
|
+
input_3: "Custom rules for documentation", // Custom rules
|
|
990
|
+
select_4: "domainFamiliar", // Reader knowledge level
|
|
991
|
+
select_5: "balancedCoverage", // Documentation depth
|
|
992
|
+
select_6: "en", // Primary language
|
|
993
|
+
checkbox_7: ["zh", "ja"], // Translation languages
|
|
994
|
+
input_8: join(tempDir, "docs"), // Documentation directory
|
|
994
995
|
search: "", // Source paths (empty to finish)
|
|
995
996
|
};
|
|
996
997
|
|
|
@@ -1023,6 +1024,7 @@ describe("init", () => {
|
|
|
1023
1024
|
|
|
1024
1025
|
expect(config.documentPurpose).toEqual(["getStarted", "findAnswers"]);
|
|
1025
1026
|
expect(config.targetAudienceTypes).toEqual(["developers"]);
|
|
1027
|
+
expect(config.rules).toBe("Custom rules for documentation");
|
|
1026
1028
|
expect(config.readerKnowledgeLevel).toBe("domainFamiliar");
|
|
1027
1029
|
expect(config.documentationDepth).toBe("balancedCoverage");
|
|
1028
1030
|
expect(config.locale).toBe("en");
|
|
@@ -1042,11 +1044,12 @@ describe("init", () => {
|
|
|
1042
1044
|
checkbox_1: ["mixedPurpose"], // Document purpose - triggers follow-up
|
|
1043
1045
|
checkbox: ["completeTasks", "findAnswers"], // Top priorities after mixedPurpose
|
|
1044
1046
|
checkbox_2: ["developers", "devops"], // Target audience
|
|
1045
|
-
|
|
1046
|
-
select_4: "
|
|
1047
|
-
select_5: "
|
|
1048
|
-
|
|
1049
|
-
|
|
1047
|
+
input_3: "Custom rules for documentation", // Custom rules
|
|
1048
|
+
select_4: "experiencedUsers", // Reader knowledge level
|
|
1049
|
+
select_5: "comprehensive", // Documentation depth
|
|
1050
|
+
select_6: "zh-CN", // Primary language
|
|
1051
|
+
checkbox_7: ["en"], // Translation languages
|
|
1052
|
+
input_8: join(tempDir, "documentation"), // Documentation directory
|
|
1050
1053
|
search: "", // Source paths (empty to finish)
|
|
1051
1054
|
};
|
|
1052
1055
|
|
|
@@ -1071,6 +1074,7 @@ describe("init", () => {
|
|
|
1071
1074
|
|
|
1072
1075
|
expect(config.documentPurpose).toEqual(["completeTasks", "findAnswers"]);
|
|
1073
1076
|
expect(config.targetAudienceTypes).toEqual(["developers", "devops"]);
|
|
1077
|
+
expect(config.rules).toBe("Custom rules for documentation");
|
|
1074
1078
|
expect(config.readerKnowledgeLevel).toBe("experiencedUsers");
|
|
1075
1079
|
expect(config.documentationDepth).toBe("comprehensive");
|
|
1076
1080
|
expect(config.locale).toBe("zh-CN");
|
|
@@ -1087,11 +1091,12 @@ describe("init", () => {
|
|
|
1087
1091
|
const mockResponses = {
|
|
1088
1092
|
checkbox_1: ["getStarted"], // Document purpose
|
|
1089
1093
|
checkbox_2: ["endUsers"], // Target audience
|
|
1090
|
-
|
|
1091
|
-
select_4: "
|
|
1092
|
-
select_5: "
|
|
1093
|
-
|
|
1094
|
-
|
|
1094
|
+
input_3: "Custom rules for documentation", // Custom rules
|
|
1095
|
+
select_4: "completeBeginners", // Reader knowledge level
|
|
1096
|
+
select_5: "essentialOnly", // Documentation depth
|
|
1097
|
+
select_6: "en", // Primary language
|
|
1098
|
+
checkbox_7: [], // No translation languages
|
|
1099
|
+
input_8: join(tempDir, "simple-docs"), // Documentation directory
|
|
1095
1100
|
search: "", // Source paths (empty to finish)
|
|
1096
1101
|
};
|
|
1097
1102
|
|
|
@@ -1115,6 +1120,7 @@ describe("init", () => {
|
|
|
1115
1120
|
|
|
1116
1121
|
expect(config.documentPurpose).toEqual(["getStarted"]);
|
|
1117
1122
|
expect(config.targetAudienceTypes).toEqual(["endUsers"]);
|
|
1123
|
+
expect(config.rules).toBe("Custom rules for documentation");
|
|
1118
1124
|
expect(config.readerKnowledgeLevel).toBe("completeBeginners");
|
|
1119
1125
|
expect(config.documentationDepth).toBe("essentialOnly");
|
|
1120
1126
|
expect(config.locale).toBe("en");
|
|
@@ -1298,7 +1304,7 @@ describe("init", () => {
|
|
|
1298
1304
|
let validateCalled = false;
|
|
1299
1305
|
const mockPrompts = {
|
|
1300
1306
|
checkbox: (options) => {
|
|
1301
|
-
if (options.message.includes("[1/
|
|
1307
|
+
if (options.message.includes("[1/9]") && options.validate) {
|
|
1302
1308
|
// Test the validation function directly
|
|
1303
1309
|
const validationResult = options.validate([]);
|
|
1304
1310
|
expect(validationResult).toBe(
|
|
@@ -1336,10 +1342,10 @@ describe("init", () => {
|
|
|
1336
1342
|
let audienceValidateCalled = false;
|
|
1337
1343
|
const mockPrompts = {
|
|
1338
1344
|
checkbox: (options) => {
|
|
1339
|
-
if (options.message.includes("[1/
|
|
1345
|
+
if (options.message.includes("[1/9]")) {
|
|
1340
1346
|
return Promise.resolve(["getStarted"]); // Valid document purpose
|
|
1341
1347
|
}
|
|
1342
|
-
if (options.message.includes("[2/
|
|
1348
|
+
if (options.message.includes("[2/9]") && options.validate) {
|
|
1343
1349
|
// Test the validation function for target audience
|
|
1344
1350
|
const validationResult = options.validate([]);
|
|
1345
1351
|
expect(validationResult).toBe("Please choose at least one audience.");
|
|
@@ -1374,7 +1380,7 @@ describe("init", () => {
|
|
|
1374
1380
|
let priorityValidateCalled = false;
|
|
1375
1381
|
const mockPrompts = {
|
|
1376
1382
|
checkbox: (options) => {
|
|
1377
|
-
if (options.message.includes("[1/
|
|
1383
|
+
if (options.message.includes("[1/9]")) {
|
|
1378
1384
|
return Promise.resolve(["mixedPurpose"]); // Trigger follow-up question
|
|
1379
1385
|
}
|
|
1380
1386
|
// This is the follow-up priority selection
|