@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.
Files changed (118) hide show
  1. package/.aigne/doc-smith/config.yaml +2 -4
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +17 -2
  4. package/README.md +1 -1
  5. package/agents/clear/choose-contents.mjs +2 -2
  6. package/agents/clear/clear-document-structure.mjs +8 -8
  7. package/agents/clear/index.yaml +1 -1
  8. package/agents/evaluate/document-structure.yaml +1 -1
  9. package/agents/generate/check-d2-diagram-valid.mjs +26 -0
  10. package/agents/generate/check-document-structure.yaml +3 -3
  11. package/agents/generate/check-need-generate-structure.mjs +8 -8
  12. package/agents/generate/document-structure-tools/add-document.mjs +3 -3
  13. package/agents/generate/document-structure-tools/delete-document.mjs +2 -2
  14. package/agents/generate/document-structure-tools/move-document.mjs +3 -2
  15. package/agents/generate/document-structure-tools/update-document.mjs +2 -2
  16. package/agents/generate/generate-d2-diagram.yaml +23 -0
  17. package/agents/generate/generate-structure.yaml +1 -1
  18. package/agents/generate/merge-d2-diagram.yaml +39 -0
  19. package/agents/generate/update-document-structure.yaml +3 -3
  20. package/agents/generate/user-review-document-structure.mjs +10 -10
  21. package/agents/init/index.mjs +18 -10
  22. package/agents/publish/publish-docs.mjs +17 -20
  23. package/agents/update/batch-generate-document.yaml +1 -1
  24. package/agents/update/check-document.mjs +2 -2
  25. package/agents/update/generate-document.yaml +25 -0
  26. package/agents/utils/check-feedback-refiner.mjs +1 -1
  27. package/agents/utils/choose-docs.mjs +1 -1
  28. package/agents/utils/load-document-all-content.mjs +3 -3
  29. package/agents/utils/load-sources.mjs +1 -1
  30. package/agents/utils/save-docs.mjs +7 -28
  31. package/aigne.yaml +2 -2
  32. package/docs/_sidebar.md +1 -1
  33. package/docs/advanced-how-it-works.md +3 -3
  34. package/docs/advanced-quality-assurance.md +1 -1
  35. package/docs/cli-reference.ja.md +151 -80
  36. package/docs/cli-reference.md +126 -55
  37. package/docs/cli-reference.zh-TW.md +133 -62
  38. package/docs/cli-reference.zh.md +143 -72
  39. package/docs/configuration-interactive-setup.md +1 -1
  40. package/docs/configuration-language-support.md +1 -1
  41. package/docs/configuration-preferences.md +1 -1
  42. package/docs/configuration.ja.md +104 -48
  43. package/docs/configuration.md +58 -2
  44. package/docs/configuration.zh-TW.md +99 -42
  45. package/docs/configuration.zh.md +78 -21
  46. package/docs/features-generate-documentation.ja.md +63 -44
  47. package/docs/features-generate-documentation.md +54 -35
  48. package/docs/features-generate-documentation.zh-TW.md +67 -48
  49. package/docs/features-generate-documentation.zh.md +61 -41
  50. package/docs/features-publish-your-docs.ja.md +69 -46
  51. package/docs/features-publish-your-docs.md +65 -42
  52. package/docs/features-publish-your-docs.zh-TW.md +73 -50
  53. package/docs/features-publish-your-docs.zh.md +67 -44
  54. package/docs/features-translate-documentation.ja.md +35 -33
  55. package/docs/features-translate-documentation.md +24 -22
  56. package/docs/features-translate-documentation.zh-TW.md +32 -30
  57. package/docs/features-translate-documentation.zh.md +29 -27
  58. package/docs/features-update-and-refine.ja.md +120 -66
  59. package/docs/features-update-and-refine.md +110 -56
  60. package/docs/features-update-and-refine.zh-TW.md +116 -62
  61. package/docs/features-update-and-refine.zh.md +118 -64
  62. package/docs/getting-started.ja.md +22 -22
  63. package/docs/getting-started.md +1 -1
  64. package/docs/getting-started.zh-TW.md +16 -16
  65. package/docs/getting-started.zh.md +28 -28
  66. package/docs/overview.md +3 -3
  67. package/docs-mcp/analyze-docs-relevance.yaml +6 -6
  68. package/docs-mcp/docs-search.yaml +1 -1
  69. package/package.json +3 -3
  70. package/prompts/common/document-structure/conflict-resolution-guidance.md +3 -3
  71. package/prompts/common/document-structure/document-structure-rules.md +2 -2
  72. package/prompts/detail/{d2-chart/rules.md → d2-diagram/rules-system.md} +41 -5
  73. package/prompts/detail/d2-diagram/rules-user.md +4 -0
  74. package/prompts/detail/document-rules.md +3 -4
  75. package/prompts/detail/generate-document.md +8 -2
  76. package/prompts/detail/update-document.md +0 -2
  77. package/prompts/evaluate/document-structure.md +6 -6
  78. package/prompts/structure/check-document-structure.md +10 -10
  79. package/prompts/structure/document-rules.md +2 -2
  80. package/prompts/structure/generate-structure-system.md +3 -3
  81. package/prompts/structure/structure-example.md +1 -1
  82. package/prompts/structure/structure-getting-started.md +1 -1
  83. package/prompts/structure/update-document-structure.md +9 -9
  84. package/prompts/utils/feedback-refiner.md +1 -1
  85. package/tests/agents/clear/choose-contents.test.mjs +1 -1
  86. package/tests/agents/clear/clear-document-structure.test.mjs +36 -30
  87. package/tests/agents/evaluate/generate-report.test.mjs +1 -1
  88. package/tests/agents/generate/check-need-generate-structure.test.mjs +1 -1
  89. package/tests/agents/generate/document-structure-tools/add-document.test.mjs +2 -2
  90. package/tests/agents/generate/document-structure-tools/delete-document.test.mjs +4 -4
  91. package/tests/agents/generate/document-structure-tools/move-document.test.mjs +3 -3
  92. package/tests/agents/generate/document-structure-tools/update-document.test.mjs +3 -3
  93. package/tests/agents/generate/user-review-document-structure.test.mjs +7 -5
  94. package/tests/agents/init/init.test.mjs +25 -19
  95. package/tests/agents/publish/publish-docs.test.mjs +99 -0
  96. package/tests/agents/update/check-document.test.mjs +1 -1
  97. package/tests/agents/utils/check-detail-result.test.mjs +2 -15
  98. package/tests/agents/utils/format-document-structure.test.mjs +5 -5
  99. package/tests/agents/utils/load-sources.test.mjs +4 -4
  100. package/tests/agents/utils/save-docs.test.mjs +1 -1
  101. package/tests/utils/auth-utils.test.mjs +1 -1
  102. package/tests/utils/conflict-detector.test.mjs +1 -1
  103. package/tests/utils/d2-utils.test.mjs +4 -4
  104. package/tests/utils/deploy.test.mjs +3 -10
  105. package/tests/utils/docs-finder-utils.test.mjs +8 -8
  106. package/tests/utils/kroki-utils.test.mjs +5 -5
  107. package/tests/utils/preferences-utils.test.mjs +5 -3
  108. package/tests/utils/save-value-to-config.test.mjs +3 -1
  109. package/types/document-structure-schema.mjs +9 -9
  110. package/utils/auth-utils.mjs +4 -0
  111. package/utils/conflict-detector.mjs +1 -1
  112. package/utils/constants/index.mjs +7 -4
  113. package/utils/d2-utils.mjs +11 -6
  114. package/utils/deploy.mjs +4 -20
  115. package/utils/docs-finder-utils.mjs +11 -11
  116. package/utils/kroki-utils.mjs +5 -4
  117. package/utils/markdown-checker.mjs +1 -21
  118. /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 document structure:
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 document structure update specialist with the strategic mindset of an **INTJ** (The Architect).
4
- You analyze user feedback and intentions to modify existing document structures using specific operations.
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 document structure integrity
15
+ - Ensure all modifications maintain documentation structure integrity
16
16
 
17
17
  Rules:
18
- ** Never generate new document structures directly. All changes must be made using Tools. **
19
- ** Use the document structure returned by Tools as the latest version, check if it satisfies the user's feedback, and if so, return the latest version directly. **
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
- - This structural plan should be reasonable and clear, capable of comprehensively displaying information from the user-provided context while providing users with logical browsing paths.
23
- - Each {{nodeName}} should include: {{nodeName}} title, a one-sentence introduction to the main information this {{nodeName}} displays, with information presentation and organization methods matching the target audience.
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 Document Structure:
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 document structure, use the document structure returned by Tools as the latest version
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
- - Document structure adjustments, adding new documents, and moving document positions are always one-time operations → `save=false`
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: "Document structure cleared",
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 plan only when no docsDir provided", async () => {
38
- // Create a test structure plan file
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("Document structure cleared successfully!");
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 plan file is actually deleted
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 plan and docs directory when docsDir provided", async () => {
60
- // Create structure plan
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("Document structure cleared successfully!");
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 plan file", async () => {
82
- // Don't create the structure plan file
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("Document structure already empty.");
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 plan but not docs directory
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("Document structure cleared successfully!");
102
- expect(result.clearedCount).toBe(1); // Only structure plan cleared
101
+ expect(result.message).toContain("Documentation Structure cleared successfully!");
102
+ expect(result.clearedCount).toBe(1); // Only documentation structure cleared
103
103
 
104
- // Verify structure plan is deleted
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 plan in current directory's 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("Document structure cleared successfully!");
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 document structure and all generated documents",
162
+ "Clear documentation structure and all generated documents",
163
163
  );
164
164
  expect(clearDocumentStructure.description).toBe(
165
- "Clear the document structure plan (structure-plan.json) and optionally the documents directory",
165
+ "Clear the documentation structure (structure-plan.json) and optionally the documents directory",
166
166
  );
167
167
  });
168
168
 
169
- test("should handle complex document structures", async () => {
170
- // Create complex structure plan
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 plan");
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 plan file removal errors", async () => {
302
- // Create a spy on rm to simulate an error for structure plan
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 plan");
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("Document structure cleanup finished with some issues.");
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 document structure plan");
320
- expect(structureResult.message).toContain("Permission denied for structure plan");
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 plan file
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("Document structure cleanup finished with some issues.");
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("Document structure cleanup finished with some issues.");
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 document structure", async () => {
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 document structure when no regeneration needed", async () => {
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 document structure", async () => {
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 document structure", async () => {
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 document structure", async () => {
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 document structure with single document", async () => {
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 document structure", async () => {
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 document structure without deleted document", async () => {
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 document structure", async () => {
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 document structure", async () => {
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 document structure", async () => {
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 document structure", async () => {
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 document structure", async () => {
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 document structure", async () => {
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 document structure provided", async () => {
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 document structure was generated to review.");
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 document structure was generated to review.");
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(expect.stringContaining("Current Document Structure"));
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 document structure update feature is unavailable.",
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
- select_3: "domainFamiliar", // Reader knowledge level
990
- select_4: "balancedCoverage", // Documentation depth
991
- select_5: "en", // Primary language
992
- checkbox_6: ["zh", "ja"], // Translation languages
993
- input_7: join(tempDir, "docs"), // Documentation directory
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
- select_3: "experiencedUsers", // Reader knowledge level
1046
- select_4: "comprehensive", // Documentation depth
1047
- select_5: "zh-CN", // Primary language
1048
- checkbox_6: ["en"], // Translation languages
1049
- input_7: join(tempDir, "documentation"), // Documentation directory
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
- select_3: "completeBeginners", // Reader knowledge level
1091
- select_4: "essentialOnly", // Documentation depth
1092
- select_5: "en", // Primary language
1093
- checkbox_6: [], // No translation languages
1094
- input_7: join(tempDir, "simple-docs"), // Documentation directory
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/8]") && options.validate) {
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/8]")) {
1345
+ if (options.message.includes("[1/9]")) {
1340
1346
  return Promise.resolve(["getStarted"]); // Valid document purpose
1341
1347
  }
1342
- if (options.message.includes("[2/8]") && options.validate) {
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/8]")) {
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