@aigne/doc-smith 0.1.0 → 0.1.1
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 +9 -0
- package/README.md +2 -0
- package/agents/detail-regenerator.yaml +2 -0
- package/agents/docs-generator.yaml +3 -0
- package/agents/team-publish-docs.yaml +3 -0
- package/aigne.yaml +12 -7
- package/docs-mcp/analyze-content-relevance.yaml +50 -0
- package/docs-mcp/analyze-docs-relevance.yaml +59 -0
- package/docs-mcp/docs-search.yaml +40 -0
- package/docs-mcp/read-doc-content.mjs +93 -0
- package/package.json +7 -7
- package/docs-mcp/aigne.yaml +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.1](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.1.0...v0.1.1) (2025-07-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* agent add alias ([7e25014](https://github.com/AIGNE-io/aigne-doc-smith/commit/7e250147309849fe0f4cc554077134d2e443d344))
|
|
9
|
+
* docs mcp add doc search ([de96e0e](https://github.com/AIGNE-io/aigne-doc-smith/commit/de96e0e08455831dc6918d5fbc59d38b6a921373))
|
|
10
|
+
* polish code ([8cb0a5c](https://github.com/AIGNE-io/aigne-doc-smith/commit/8cb0a5ce67cf009c672b2fb1aa9b89ef6d965a86))
|
|
11
|
+
|
|
3
12
|
## [0.1.0](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.0.2...v0.1.0) (2025-07-31)
|
|
4
13
|
|
|
5
14
|
|
package/README.md
CHANGED
package/aigne.yaml
CHANGED
|
@@ -29,15 +29,20 @@ agents:
|
|
|
29
29
|
- ./agents/load-config.mjs
|
|
30
30
|
- ./agents/team-publish-docs.yaml
|
|
31
31
|
- ./agents/find-item-by-path.mjs
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
- ./docs-mcp/get-docs-structure.mjs
|
|
33
|
+
- ./docs-mcp/get-docs-detail.mjs
|
|
34
|
+
- ./docs-mcp/docs-search.yaml
|
|
35
|
+
- ./docs-mcp/analyze-docs-relevance.yaml
|
|
36
|
+
- ./docs-mcp/read-doc-content.mjs
|
|
37
|
+
- ./docs-mcp/analyze-content-relevance.yaml
|
|
38
38
|
cli:
|
|
39
39
|
agents:
|
|
40
40
|
- ./agents/input-generator.mjs
|
|
41
41
|
- ./agents/docs-generator.yaml
|
|
42
42
|
- ./agents/detail-regenerator.yaml
|
|
43
|
-
- ./agents/publish-docs.
|
|
43
|
+
- ./agents/team-publish-docs.yaml
|
|
44
|
+
mcp_server:
|
|
45
|
+
agents:
|
|
46
|
+
- ./docs-mcp/get-docs-structure.mjs
|
|
47
|
+
- ./docs-mcp/get-docs-detail.mjs
|
|
48
|
+
- ./docs-mcp/docs-search.yaml
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: analyze-content-relevance
|
|
2
|
+
description: Analyze document content relevance to user query and extract relevant information
|
|
3
|
+
instructions: |
|
|
4
|
+
You are an AI assistant that analyzes the relevance between user queries and document content.
|
|
5
|
+
|
|
6
|
+
<user-query>
|
|
7
|
+
{{ query }}
|
|
8
|
+
</user-query>
|
|
9
|
+
|
|
10
|
+
<document-content>
|
|
11
|
+
{{ allDocumentsText }}
|
|
12
|
+
</document-content>
|
|
13
|
+
|
|
14
|
+
Given a user query and multiple document contents, your task is to:
|
|
15
|
+
1. Understand the user's specific information needs from the query
|
|
16
|
+
2. Analyze document content for relevance to the query
|
|
17
|
+
3. Extract and synthesize the most relevant information from the documents
|
|
18
|
+
4. Provide a comprehensive answer that directly addresses the user's query
|
|
19
|
+
5. Answer user questions based on the given document content, do not return false or non-existent information
|
|
20
|
+
|
|
21
|
+
Guidelines:
|
|
22
|
+
- Focus on information that directly answers the user's question
|
|
23
|
+
- Extract specific facts, examples, and explanations from the documents
|
|
24
|
+
- Organize the information logically and coherently
|
|
25
|
+
- Include relevant code examples, configuration details, or step-by-step instructions when available
|
|
26
|
+
- Cite the source documents when referencing specific information
|
|
27
|
+
- If multiple documents contain related information, synthesize them into a unified response
|
|
28
|
+
- If no relevant information is found, clearly state this
|
|
29
|
+
|
|
30
|
+
Format your response as a comprehensive answer that:
|
|
31
|
+
- Directly addresses the user's query
|
|
32
|
+
- Includes relevant excerpts from the documents
|
|
33
|
+
- Provides context and explanations where needed
|
|
34
|
+
- Is well-structured and easy to understand
|
|
35
|
+
includeInputInOutput: false
|
|
36
|
+
input_schema:
|
|
37
|
+
type: object
|
|
38
|
+
properties:
|
|
39
|
+
query:
|
|
40
|
+
type: string
|
|
41
|
+
description: User search query
|
|
42
|
+
allDocumentsText:
|
|
43
|
+
type: string
|
|
44
|
+
description: Combined text content of all successfully read documents
|
|
45
|
+
output_schema:
|
|
46
|
+
type: object
|
|
47
|
+
properties:
|
|
48
|
+
relevantContent:
|
|
49
|
+
type: string
|
|
50
|
+
description: Comprehensive answer synthesizing relevant information from documents
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: analyze-docs-relevance
|
|
2
|
+
description: Analyze which documents in the structure plan are relevant to the user query
|
|
3
|
+
instructions: |
|
|
4
|
+
You are an AI assistant that analyzes the relevance between a user query and documents in a structure plan.
|
|
5
|
+
|
|
6
|
+
<structure-plan>
|
|
7
|
+
{{ originalStructurePlan }}
|
|
8
|
+
</structure-plan>
|
|
9
|
+
|
|
10
|
+
<user-query>
|
|
11
|
+
{{ query }}
|
|
12
|
+
</user-query>
|
|
13
|
+
|
|
14
|
+
Given a user query and a structure plan containing multiple documents, your task is to:
|
|
15
|
+
1. Understand the user's search intent from the query
|
|
16
|
+
2. Analyze each document in the structure plan to determine relevance
|
|
17
|
+
3. Return a list of relevant documents with their paths, titles, and descriptions
|
|
18
|
+
|
|
19
|
+
Consider the following factors for relevance:
|
|
20
|
+
- Semantic similarity between query and document title/description
|
|
21
|
+
- Topic alignment
|
|
22
|
+
- User intent matching
|
|
23
|
+
- Content scope overlap
|
|
24
|
+
|
|
25
|
+
Return only the most relevant documents (top 5-10) to avoid overwhelming results.
|
|
26
|
+
|
|
27
|
+
Format your response as a JSON object with:
|
|
28
|
+
- relevantDocs: array of relevant document paths
|
|
29
|
+
- reasoning: brief explanation of why these documents were selected
|
|
30
|
+
input_schema:
|
|
31
|
+
type: object
|
|
32
|
+
properties:
|
|
33
|
+
query:
|
|
34
|
+
type: string
|
|
35
|
+
description: User search query
|
|
36
|
+
originalStructurePlan:
|
|
37
|
+
type: array
|
|
38
|
+
items:
|
|
39
|
+
type: object
|
|
40
|
+
properties:
|
|
41
|
+
path:
|
|
42
|
+
type: string
|
|
43
|
+
title:
|
|
44
|
+
type: string
|
|
45
|
+
description:
|
|
46
|
+
type: string
|
|
47
|
+
description: Structure plan containing all available documents
|
|
48
|
+
output_schema:
|
|
49
|
+
type: object
|
|
50
|
+
properties:
|
|
51
|
+
relevantDocPaths:
|
|
52
|
+
type: array
|
|
53
|
+
items:
|
|
54
|
+
type: string
|
|
55
|
+
description: Must be selected from paths in the structure plan, cannot be other paths
|
|
56
|
+
description: List of relevant documents
|
|
57
|
+
reasoning:
|
|
58
|
+
type: string
|
|
59
|
+
description: Brief explanation of document selection
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type: team
|
|
2
|
+
name: docs-search
|
|
3
|
+
description: Search relevant documents based on user query
|
|
4
|
+
skills:
|
|
5
|
+
- ../agents/load-config.mjs
|
|
6
|
+
- ../agents/load-sources.mjs
|
|
7
|
+
- analyze-docs-relevance.yaml
|
|
8
|
+
- read-doc-content.mjs
|
|
9
|
+
- analyze-content-relevance.yaml
|
|
10
|
+
includeInputInOutput: false
|
|
11
|
+
input_schema:
|
|
12
|
+
type: object
|
|
13
|
+
properties:
|
|
14
|
+
query:
|
|
15
|
+
type: string
|
|
16
|
+
description: User search query
|
|
17
|
+
required: true
|
|
18
|
+
config:
|
|
19
|
+
type: string
|
|
20
|
+
description: Path to the config file
|
|
21
|
+
default: ./doc-smith/config.yaml
|
|
22
|
+
output_schema:
|
|
23
|
+
type: object
|
|
24
|
+
properties:
|
|
25
|
+
relevantContent:
|
|
26
|
+
type: string
|
|
27
|
+
description: AI analyzed relevant content from documents
|
|
28
|
+
relevantDocs:
|
|
29
|
+
type: array
|
|
30
|
+
items:
|
|
31
|
+
type: object
|
|
32
|
+
properties:
|
|
33
|
+
path:
|
|
34
|
+
type: string
|
|
35
|
+
title:
|
|
36
|
+
type: string
|
|
37
|
+
description:
|
|
38
|
+
type: string
|
|
39
|
+
description: List of relevant documents from structure plan
|
|
40
|
+
mode: sequential
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
const docsDir = path.join(process.cwd(), "doc-smith", "docs");
|
|
5
|
+
|
|
6
|
+
export default async function readDocContent({
|
|
7
|
+
relevantDocPaths,
|
|
8
|
+
docsDir: customDocsDir,
|
|
9
|
+
}) {
|
|
10
|
+
const targetDocsDir = customDocsDir || docsDir;
|
|
11
|
+
const docContents = [];
|
|
12
|
+
|
|
13
|
+
for (const docPath of relevantDocPaths) {
|
|
14
|
+
try {
|
|
15
|
+
// Flatten path: remove leading /, replace all / with - (same logic as utils.mjs)
|
|
16
|
+
const flatName = docPath.replace(/^\//, "").replace(/\//g, "-");
|
|
17
|
+
const fileFullName = `${flatName}.md`;
|
|
18
|
+
const filePath = path.join(targetDocsDir, fileFullName);
|
|
19
|
+
|
|
20
|
+
// Read the markdown file
|
|
21
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
22
|
+
|
|
23
|
+
docContents.push({
|
|
24
|
+
success: true,
|
|
25
|
+
path: docPath,
|
|
26
|
+
content,
|
|
27
|
+
filePath,
|
|
28
|
+
});
|
|
29
|
+
} catch (error) {
|
|
30
|
+
docContents.push({
|
|
31
|
+
success: false,
|
|
32
|
+
path: docPath,
|
|
33
|
+
error: error.message,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Combine all successful document contents into a single text
|
|
39
|
+
const allDocumentsText = docContents
|
|
40
|
+
.filter((doc) => doc.success)
|
|
41
|
+
.map((doc) => doc.content)
|
|
42
|
+
.join("\n\n---\n\n");
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
docContents,
|
|
46
|
+
allDocumentsText,
|
|
47
|
+
totalDocs: relevantDocPaths.length,
|
|
48
|
+
successfulReads: docContents.filter((doc) => doc.success).length,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
readDocContent.input_schema = {
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {
|
|
55
|
+
relevantDocPaths: {
|
|
56
|
+
type: "array",
|
|
57
|
+
items: { type: "string" },
|
|
58
|
+
description: "List of document paths to read",
|
|
59
|
+
},
|
|
60
|
+
docsDir: {
|
|
61
|
+
type: "string",
|
|
62
|
+
description: "Custom docs directory path (optional)",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
required: ["relevantDocPaths"],
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
readDocContent.output_schema = {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
docContents: {
|
|
72
|
+
type: "array",
|
|
73
|
+
items: {
|
|
74
|
+
type: "object",
|
|
75
|
+
properties: {
|
|
76
|
+
success: { type: "boolean" },
|
|
77
|
+
path: { type: "string" },
|
|
78
|
+
content: { type: "string" },
|
|
79
|
+
filePath: { type: "string" },
|
|
80
|
+
error: { type: "string" },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
allDocumentsText: {
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "Combined text content of all successfully read documents",
|
|
87
|
+
},
|
|
88
|
+
totalDocs: { type: "number" },
|
|
89
|
+
successfulReads: { type: "number" },
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
readDocContent.description = "Read markdown content for multiple documents";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/doc-smith",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@aigne/anthropic": "^0.10.
|
|
16
|
-
"@aigne/cli": "^1.
|
|
17
|
-
"@aigne/core": "^1.
|
|
18
|
-
"@aigne/gemini": "^0.8.
|
|
19
|
-
"@aigne/openai": "^0.10.
|
|
20
|
-
"@aigne/publish-docs": "^0.5.
|
|
15
|
+
"@aigne/anthropic": "^0.10.4",
|
|
16
|
+
"@aigne/cli": "^1.29.0",
|
|
17
|
+
"@aigne/core": "^1.41.0",
|
|
18
|
+
"@aigne/gemini": "^0.8.8",
|
|
19
|
+
"@aigne/openai": "^0.10.8",
|
|
20
|
+
"@aigne/publish-docs": "^0.5.1",
|
|
21
21
|
"glob": "^11.0.3",
|
|
22
22
|
"open": "^10.2.0",
|
|
23
23
|
"ufo": "^1.6.1",
|