@aigne/doc-smith 0.8.15-beta.9 → 0.8.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/agents/evaluate/document-structure.yaml +3 -1
- package/agents/evaluate/document.yaml +3 -1
- package/agents/generate/generate-structure.yaml +1 -5
- package/agents/generate/merge-diagram.yaml +4 -4
- package/agents/generate/update-document-structure.yaml +51 -45
- package/agents/generate/user-review-document-structure.mjs +3 -26
- package/agents/generate/utils/merge-document-structures.mjs +4 -4
- package/agents/init/check.mjs +1 -1
- package/agents/init/index.mjs +52 -2
- package/agents/init/validate.mjs +16 -0
- package/agents/publish/publish-docs.mjs +16 -10
- package/agents/schema/document-execution-structure.yaml +1 -1
- package/agents/schema/document-structure-item.yaml +1 -1
- package/agents/schema/document-structure.yaml +4 -2
- package/agents/update/check-generate-diagram.mjs +74 -16
- package/agents/update/generate-document.yaml +1 -13
- package/agents/update/handle-document-update.yaml +1 -1
- package/agents/update/pre-check-generate-diagram.yaml +44 -0
- package/agents/update/update-document-detail.yaml +64 -58
- package/agents/update/update-single-document.yaml +1 -1
- package/agents/update/user-review-document.mjs +2 -1
- package/agents/utils/analyze-feedback-intent.yaml +29 -0
- package/agents/utils/choose-docs.mjs +16 -6
- package/agents/utils/find-item-by-path.mjs +4 -2
- package/agents/utils/load-sources.mjs +4 -4
- package/agents/utils/map-reasoning-effort-level.mjs +15 -0
- package/agents/utils/save-sidebar.mjs +12 -33
- package/agents/utils/{transform-detail-datasources.mjs → transform-detail-data-sources.mjs} +2 -2
- package/aigne.yaml +7 -3
- package/package.json +10 -9
- package/prompts/common/document/content-rules-core.md +5 -5
- package/prompts/common/document-structure/conflict-resolution-guidance.md +2 -2
- package/prompts/common/document-structure/document-structure-rules.md +8 -8
- package/prompts/common/document-structure/output-constraints.md +3 -3
- package/prompts/detail/custom/custom-code-block.md +36 -1
- package/prompts/detail/custom/{custom-components.md → custom-components-usage-rules.md} +29 -7
- package/prompts/detail/d2-diagram/pre-check.md +23 -0
- package/prompts/detail/d2-diagram/rules.md +42 -24
- package/prompts/detail/d2-diagram/user-prompt.md +0 -20
- package/prompts/detail/generate/document-rules.md +2 -2
- package/prompts/detail/generate/system-prompt.md +3 -3
- package/prompts/detail/generate/user-prompt.md +5 -5
- package/prompts/detail/update/system-prompt.md +4 -3
- package/prompts/detail/update/user-prompt.md +8 -4
- package/prompts/evaluate/document.md +0 -4
- package/prompts/structure/check-document-structure.md +4 -4
- package/prompts/structure/generate/system-prompt.md +0 -1
- package/prompts/structure/generate/user-prompt.md +14 -9
- package/prompts/structure/review/structure-review-system.md +5 -2
- package/prompts/structure/update/system-prompt.md +0 -13
- package/prompts/structure/update/user-prompt.md +6 -5
- package/prompts/translate/translate-document.md +3 -3
- package/prompts/utils/analyze-feedback-intent.md +55 -0
- package/utils/constants/index.mjs +38 -0
- package/utils/deploy.mjs +3 -1
- package/utils/docs-finder-utils.mjs +37 -3
- package/utils/file-utils.mjs +97 -0
- package/utils/load-config.mjs +19 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<role>
|
|
2
|
+
You are a feedback intent analyzer. Your task is to determine whether data sources are needed to fulfill the user's feedback about content modifications.
|
|
3
|
+
</role>
|
|
4
|
+
|
|
5
|
+
<input>
|
|
6
|
+
- feedback: {{feedback}}
|
|
7
|
+
</input>
|
|
8
|
+
|
|
9
|
+
<analysis_rules>
|
|
10
|
+
**Determining Data Source Necessity:**
|
|
11
|
+
|
|
12
|
+
You need to analyze the user's feedback and categorize it into different intent types. Based on the intent type, determine if data sources are required.
|
|
13
|
+
|
|
14
|
+
This analyzer is generic and can be used for any content modification scenarios (documentation structure, document content, translations, etc.).
|
|
15
|
+
|
|
16
|
+
**Intent Types:**
|
|
17
|
+
|
|
18
|
+
1. **add** - Adding new items, sections, or content
|
|
19
|
+
- Requires data sources: **YES**
|
|
20
|
+
- Reason: Need sufficient context from codebase or related materials to generate accurate new content
|
|
21
|
+
|
|
22
|
+
2. **edit** - Modifying existing content, descriptions, titles, or properties
|
|
23
|
+
- Requires data sources: **YES**
|
|
24
|
+
- Reason: Need context to ensure modifications are accurate and contextually appropriate
|
|
25
|
+
|
|
26
|
+
3. **delete** - Removing items, sections, or content
|
|
27
|
+
- Requires data sources: **NO**
|
|
28
|
+
- Reason: Deletion only needs to identify what to remove, no new content generation needed
|
|
29
|
+
|
|
30
|
+
4. **move** - Moving items to different positions or parent sections
|
|
31
|
+
- Requires data sources: **NO**
|
|
32
|
+
- Reason: Only changing item location in the structure, no content changes needed
|
|
33
|
+
|
|
34
|
+
5. **reorder** - Changing the order of items at the same level
|
|
35
|
+
- Requires data sources: **NO**
|
|
36
|
+
- Reason: Only rearranging sequence, no content generation needed
|
|
37
|
+
|
|
38
|
+
6. **mixed** - Combination of multiple intent types
|
|
39
|
+
- Requires data sources: **Depends on whether add/edit operations are included**
|
|
40
|
+
- Reason: If the feedback includes any add or edit operations, data sources are needed
|
|
41
|
+
|
|
42
|
+
**Decision Logic:**
|
|
43
|
+
- If the feedback contains ANY add or edit operations → `needDataSources = true`
|
|
44
|
+
- If the feedback ONLY contains delete, move, or reorder operations → `needDataSources = false`
|
|
45
|
+
- When in doubt, default to `needDataSources = true` to ensure sufficient context
|
|
46
|
+
</analysis_rules>
|
|
47
|
+
|
|
48
|
+
<output_rules>
|
|
49
|
+
Return a JSON object with:
|
|
50
|
+
- `needDataSources`: boolean indicating if data sources are required
|
|
51
|
+
- `intentType`: the primary intent type (add, edit, delete, move, reorder, or mixed)
|
|
52
|
+
- `reason`: clear explanation of why data sources are or aren't needed
|
|
53
|
+
|
|
54
|
+
Analyze the feedback carefully and be conservative - when uncertain, prefer `needDataSources: true` to ensure sufficient context is available.
|
|
55
|
+
</output_rules>
|
|
@@ -549,3 +549,41 @@ export const DOC_SMITH_DIR = ".aigne/doc-smith";
|
|
|
549
549
|
export const TMP_DIR = ".tmp";
|
|
550
550
|
export const TMP_DOCS_DIR = "docs";
|
|
551
551
|
export const TMP_ASSETS_DIR = "assets";
|
|
552
|
+
|
|
553
|
+
export const DOC_ACTION = {
|
|
554
|
+
translate: "translate",
|
|
555
|
+
update: "update",
|
|
556
|
+
clear: "clear",
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
// Default thinking effort level, available options: 'lite', 'standard', 'pro'
|
|
560
|
+
// This level can be defined by the user in the config file to influence reasoning effort mapping
|
|
561
|
+
export const DEFAULT_THINKING_EFFORT_LEVEL = "standard";
|
|
562
|
+
|
|
563
|
+
// Default reasoning effort level, available options: 'minimal', 'low', 'medium', 'high'
|
|
564
|
+
export const DEFAULT_REASONING_EFFORT_LEVEL = "low";
|
|
565
|
+
|
|
566
|
+
export const DEFAULT_REASONING_EFFORT_VALUE = 500;
|
|
567
|
+
|
|
568
|
+
export const REASONING_EFFORT_LEVELS = {
|
|
569
|
+
minimal: {
|
|
570
|
+
lite: 100,
|
|
571
|
+
standard: 300,
|
|
572
|
+
pro: 500,
|
|
573
|
+
},
|
|
574
|
+
low: {
|
|
575
|
+
lite: 200,
|
|
576
|
+
standard: 500,
|
|
577
|
+
pro: 1000,
|
|
578
|
+
},
|
|
579
|
+
medium: {
|
|
580
|
+
lite: 300,
|
|
581
|
+
standard: 800,
|
|
582
|
+
pro: 1500,
|
|
583
|
+
},
|
|
584
|
+
high: {
|
|
585
|
+
lite: 500,
|
|
586
|
+
standard: 1000,
|
|
587
|
+
pro: 2000,
|
|
588
|
+
},
|
|
589
|
+
};
|
package/utils/deploy.mjs
CHANGED
|
@@ -31,6 +31,7 @@ export async function deploy(id, cachedUrl) {
|
|
|
31
31
|
const result = await client.deploy({
|
|
32
32
|
cachedCheckoutId: id,
|
|
33
33
|
cachedPaymentUrl: cachedUrl,
|
|
34
|
+
needShortUrl: true,
|
|
34
35
|
pageInfo: { successMessage: SUCCESS_MESSAGE },
|
|
35
36
|
hooks: {
|
|
36
37
|
[STEPS.PAYMENT_PENDING]: async ({ sessionId, paymentUrl, isResuming }) => {
|
|
@@ -71,7 +72,7 @@ export async function deploy(id, cachedUrl) {
|
|
|
71
72
|
},
|
|
72
73
|
});
|
|
73
74
|
|
|
74
|
-
const { appUrl, homeUrl, subscriptionUrl, dashboardUrl, vendors } = result;
|
|
75
|
+
const { appUrl, homeUrl, subscriptionUrl, dashboardUrl, vendors, sessionId } = result;
|
|
75
76
|
const token = vendors?.[0]?.token;
|
|
76
77
|
|
|
77
78
|
return {
|
|
@@ -80,5 +81,6 @@ export async function deploy(id, cachedUrl) {
|
|
|
80
81
|
dashboardUrl,
|
|
81
82
|
subscriptionUrl,
|
|
82
83
|
token,
|
|
84
|
+
sessionId,
|
|
83
85
|
};
|
|
84
86
|
}
|
|
@@ -4,12 +4,11 @@ import { pathExists } from "./file-utils.mjs";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Get action-specific text based on isTranslate flag
|
|
7
|
-
* @param {boolean} isTranslate - Whether this is a translation action
|
|
8
7
|
* @param {string} baseText - Base text template with {action} placeholder
|
|
8
|
+
* @param {string} action - doc action type
|
|
9
9
|
* @returns {string} Text with action replaced
|
|
10
10
|
*/
|
|
11
|
-
export function getActionText(
|
|
12
|
-
const action = isTranslate ? "translate" : "update";
|
|
11
|
+
export function getActionText(baseText, action) {
|
|
13
12
|
return baseText.replace("{action}", action);
|
|
14
13
|
}
|
|
15
14
|
|
|
@@ -324,3 +323,38 @@ export async function loadDocumentStructure(outputDir) {
|
|
|
324
323
|
return null;
|
|
325
324
|
}
|
|
326
325
|
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Build a tree structure from a flat document structure array using parentId
|
|
329
|
+
* @param {Array} documentStructure - Flat array of document structure items with path and parentId
|
|
330
|
+
* @returns {Object} Object containing rootNodes (array of root nodes) and nodeMap (Map for lookups)
|
|
331
|
+
*/
|
|
332
|
+
export function buildDocumentTree(documentStructure) {
|
|
333
|
+
// Create a map of nodes for easy lookup
|
|
334
|
+
const nodeMap = new Map();
|
|
335
|
+
const rootNodes = [];
|
|
336
|
+
|
|
337
|
+
// First pass: create node map
|
|
338
|
+
documentStructure.forEach((node) => {
|
|
339
|
+
nodeMap.set(node.path, {
|
|
340
|
+
...node,
|
|
341
|
+
children: [],
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// Build the tree structure using parentId
|
|
346
|
+
documentStructure.forEach((node) => {
|
|
347
|
+
if (node.parentId) {
|
|
348
|
+
const parent = nodeMap.get(node.parentId);
|
|
349
|
+
if (parent) {
|
|
350
|
+
parent.children.push(nodeMap.get(node.path));
|
|
351
|
+
} else {
|
|
352
|
+
rootNodes.push(nodeMap.get(node.path));
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
rootNodes.push(nodeMap.get(node.path));
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
return { rootNodes, nodeMap };
|
|
360
|
+
}
|
package/utils/file-utils.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { debug } from "./debug.mjs";
|
|
|
13
13
|
import { isGlobPattern } from "./utils.mjs";
|
|
14
14
|
import { uploadFiles } from "./upload-files.mjs";
|
|
15
15
|
import { extractApi } from "./extract-api.mjs";
|
|
16
|
+
import { minimatch } from "minimatch";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Check if a directory is inside a git repository using git command
|
|
@@ -859,3 +860,99 @@ export async function downloadAndUploadImage(imageUrl, docsDir, appUrl, accessTo
|
|
|
859
860
|
return { url: imageUrl, downloadFinalPath: null };
|
|
860
861
|
}
|
|
861
862
|
}
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Extract the path prefix from a glob pattern until the first glob character
|
|
866
|
+
*/
|
|
867
|
+
export function getPathPrefix(pattern) {
|
|
868
|
+
const segments = pattern.split("/");
|
|
869
|
+
const result = [];
|
|
870
|
+
|
|
871
|
+
for (const segment of segments) {
|
|
872
|
+
if (isGlobPattern(segment)) {
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
result.push(segment);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
return result.join("/") || ".";
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Check if a dir matches any exclude pattern
|
|
883
|
+
*/
|
|
884
|
+
export function isDirExcluded(dir, excludePatterns) {
|
|
885
|
+
if (!dir || typeof dir !== "string") {
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
let normalizedDir = dir.replace(/\\/g, "/").replace(/^\.\/+/, "");
|
|
890
|
+
normalizedDir = normalizedDir.endsWith("/") ? normalizedDir : `${normalizedDir}/`;
|
|
891
|
+
|
|
892
|
+
for (const excludePattern of excludePatterns) {
|
|
893
|
+
if (minimatch(normalizedDir, excludePattern, { dot: true })) {
|
|
894
|
+
return true;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
return false;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Return source paths that would be excluded by exclude patterns (files are skipped, directories use minimatch, glob patterns use path prefix heuristic)
|
|
903
|
+
*/
|
|
904
|
+
export async function findInvalidSourcePaths(sourcePaths, excludePatterns) {
|
|
905
|
+
if (!Array.isArray(sourcePaths) || sourcePaths.length === 0) {
|
|
906
|
+
return [];
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
if (!Array.isArray(excludePatterns) || excludePatterns.length === 0) {
|
|
910
|
+
return [];
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
const invalidPaths = [];
|
|
914
|
+
|
|
915
|
+
for (const sourcePath of sourcePaths) {
|
|
916
|
+
if (typeof sourcePath !== "string" || !sourcePath) {
|
|
917
|
+
continue;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// Skip paths starting with "!" (exclusion patterns)
|
|
921
|
+
if (sourcePath.startsWith("!")) {
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// Skip remote URLs
|
|
926
|
+
if (isRemoteFile(sourcePath)) {
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
// Check glob pattern: use heuristic algorithm
|
|
931
|
+
if (isGlobPattern(sourcePath)) {
|
|
932
|
+
const representativePath = getPathPrefix(sourcePath);
|
|
933
|
+
if (isDirExcluded(representativePath, excludePatterns)) {
|
|
934
|
+
invalidPaths.push(sourcePath);
|
|
935
|
+
}
|
|
936
|
+
continue;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
try {
|
|
940
|
+
const stats = await stat(sourcePath);
|
|
941
|
+
// Skip file
|
|
942
|
+
if (stats.isFile()) {
|
|
943
|
+
continue;
|
|
944
|
+
}
|
|
945
|
+
// Check dir with minimatch
|
|
946
|
+
if (stats.isDirectory()) {
|
|
947
|
+
if (isDirExcluded(sourcePath, excludePatterns)) {
|
|
948
|
+
invalidPaths.push(sourcePath);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
} catch {
|
|
952
|
+
// Path doesn't exist
|
|
953
|
+
invalidPaths.push(sourcePath);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
return invalidPaths;
|
|
958
|
+
}
|
package/utils/load-config.mjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { parse } from "yaml";
|
|
4
5
|
import { processConfigFields, resolveFileReferences } from "./utils.mjs";
|
|
6
|
+
import { DEFAULT_EXCLUDE_PATTERNS } from "./constants/index.mjs";
|
|
7
|
+
import { findInvalidSourcePaths, toDisplayPath } from "./file-utils.mjs";
|
|
5
8
|
|
|
6
9
|
export default async function loadConfig({ config, appUrl }) {
|
|
7
10
|
const configPath = path.isAbsolute(config) ? config : path.join(process.cwd(), config);
|
|
@@ -30,6 +33,22 @@ export default async function loadConfig({ config, appUrl }) {
|
|
|
30
33
|
// Parse new configuration fields and convert keys to actual content
|
|
31
34
|
const processedConfig = await processConfigFields(parsedConfig);
|
|
32
35
|
|
|
36
|
+
// Validate sourcePaths against exclude patterns
|
|
37
|
+
const sourcesPath = processedConfig.sourcesPath || parsedConfig.sourcesPath;
|
|
38
|
+
if (sourcesPath) {
|
|
39
|
+
const excludePatterns = [
|
|
40
|
+
...DEFAULT_EXCLUDE_PATTERNS,
|
|
41
|
+
...(processedConfig.excludePatterns || parsedConfig.excludePatterns || []),
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const invalidPaths = await findInvalidSourcePaths(sourcesPath, excludePatterns);
|
|
45
|
+
if (invalidPaths.length > 0) {
|
|
46
|
+
console.warn(
|
|
47
|
+
`⚠️ Some source paths have been excluded and will not be processed:\n${invalidPaths.map((p) => ` - ${chalk.yellow(p)}`).join("\n")}\n💡 Tip: You can remove these paths in ${toDisplayPath(configPath)}\n`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
33
52
|
return {
|
|
34
53
|
lastGitHead: parsedConfig.lastGitHead || "",
|
|
35
54
|
...parsedConfig,
|