@aigne/doc-smith 0.8.15-beta.11 → 0.8.15-beta.13

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.15-beta.13](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.12...v0.8.15-beta.13) (2025-11-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * make paid deployment more smooth stable ([#266](https://github.com/AIGNE-io/aigne-doc-smith/issues/266)) ([ce8c00a](https://github.com/AIGNE-io/aigne-doc-smith/commit/ce8c00ab3eb045c482e07dc3c4e3bd149e754a06))
9
+ * validate docsDir on init and ensure latest doc on view after publish ([#267](https://github.com/AIGNE-io/aigne-doc-smith/issues/267)) ([e45864d](https://github.com/AIGNE-io/aigne-doc-smith/commit/e45864da4a7fb5b09af2bbffdb7ca93abd74397c))
10
+
11
+ ## [0.8.15-beta.12](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.11...v0.8.15-beta.12) (2025-11-05)
12
+
13
+
14
+ ### Features
15
+
16
+ * tune token consumption for update ops with intent analysis ([#264](https://github.com/AIGNE-io/aigne-doc-smith/issues/264)) ([8c53d28](https://github.com/AIGNE-io/aigne-doc-smith/commit/8c53d288346ae622e8841866db1b6fbed9d5023d))
17
+
3
18
  ## [0.8.15-beta.11](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.10...v0.8.15-beta.11) (2025-11-04)
4
19
 
5
20
 
@@ -1,48 +1,54 @@
1
- type: ai
1
+ type: team
2
2
  name: updateDocumentStructure
3
3
  description: Update documentation structure based on user feedback and intentions using structure modification tools
4
- instructions:
5
- - role: system
6
- url: ../../prompts/structure/update/system-prompt.md
7
- - role: user
8
- url: ../../prompts/structure/update/user-prompt.md
9
- input_schema:
10
- type: object
11
- properties:
12
- documentStructure: ../schema/document-structure.yaml
13
- rules:
14
- type: string
15
- description: User configuration rules
16
- locale:
17
- type: string
18
- description: User language, e.g. zh, en
19
- dataSourceChunk:
20
- type: string
21
- description: Context for documentation structure
22
- glossary:
23
- type: string
24
- description: Glossary of terms
25
- feedback:
26
- type: string
27
- description: User feedback for structure modifications
28
- userPreferences:
29
- type: string
30
- description: Your saved preferences for structure and documentation style
31
- required:
32
- - documentStructure
33
- - feedback
34
- output_key: message
35
- afs:
36
- modules:
37
- - module: system-fs
38
- options:
39
- mount: /sources
40
- path: .
41
- description: |
42
- Codebase of the project to be documented used as context for document generation,
43
- should search and read as needed while generating document content
44
4
  skills:
45
- - ./document-structure-tools/add-document.mjs
46
- - ./document-structure-tools/delete-document.mjs
47
- - ./document-structure-tools/update-document.mjs
48
- - ./document-structure-tools/move-document.mjs
5
+ - url: ../utils/analyze-feedback-intent.yaml
6
+ - type: ai
7
+ instructions:
8
+ - role: system
9
+ url: ../../prompts/structure/update/system-prompt.md
10
+ - role: user
11
+ url: ../../prompts/structure/update/user-prompt.md
12
+ input_schema:
13
+ type: object
14
+ properties:
15
+ documentStructure: ../schema/document-structure.yaml
16
+ rules:
17
+ type: string
18
+ description: User configuration rules
19
+ locale:
20
+ type: string
21
+ description: User language, e.g. zh, en
22
+ dataSourceChunk:
23
+ type: string
24
+ description: Context for documentation structure
25
+ glossary:
26
+ type: string
27
+ description: Glossary of terms
28
+ feedback:
29
+ type: string
30
+ description: User feedback for structure modifications
31
+ userPreferences:
32
+ type: string
33
+ description: Your saved preferences for structure and documentation style
34
+ needDataSources:
35
+ type: boolean
36
+ description: Whether data sources are needed for content modifications
37
+ required:
38
+ - documentStructure
39
+ - feedback
40
+ output_key: message
41
+ afs:
42
+ modules:
43
+ - module: system-fs
44
+ options:
45
+ mount: /sources
46
+ path: .
47
+ description: |
48
+ Codebase of the project to be documented used as context for document generation,
49
+ should search and read as needed while generating document content
50
+ skills:
51
+ - ./document-structure-tools/add-document.mjs
52
+ - ./document-structure-tools/delete-document.mjs
53
+ - ./document-structure-tools/update-document.mjs
54
+ - ./document-structure-tools/move-document.mjs
@@ -21,6 +21,7 @@ import {
21
21
  validatePath,
22
22
  } from "../../utils/utils.mjs";
23
23
  import { isRemoteFile } from "../../utils/file-utils.mjs";
24
+ import { validateDocDir } from "./validate.mjs";
24
25
 
25
26
  const _PRESS_ENTER_TO_FINISH = "Press Enter to finish";
26
27
 
@@ -64,7 +65,19 @@ export default async function init(
64
65
  // Only skip if file exists AND has non-empty content
65
66
  if (configContent && configContent.trim() !== "") {
66
67
  // load config from file
67
- return loadConfig({ config: filePath, appUrl });
68
+ const config = await loadConfig({ config: filePath, appUrl });
69
+ const isValid = validateDocDir(config.docsDir);
70
+ if (typeof isValid === "string") {
71
+ console.log(
72
+ `${chalk.red("Invalid docsDir")}: ${isValid}\nPlease check your configuration.`,
73
+ );
74
+ process.exit(1);
75
+ }
76
+ if (!isValid) {
77
+ console.log(`${chalk.red("Invalid docsDir")}, please check your configuration.`);
78
+ process.exit(1);
79
+ }
80
+ return config;
68
81
  }
69
82
  }
70
83
 
@@ -241,6 +254,7 @@ export default async function init(
241
254
  const docsDirInput = await options.prompts.input({
242
255
  message: `📁 [7/9]: Where should we save your documentation?`,
243
256
  default: `${outputPath}/docs`,
257
+ validate: validateDocDir,
244
258
  });
245
259
  input.docsDir = docsDirInput.trim() || `${outputPath}/docs`;
246
260
 
@@ -0,0 +1,16 @@
1
+ import path from "node:path";
2
+ export function validateDocDir(input) {
3
+ const currentDir = process.cwd();
4
+ const targetDir = path.resolve(input);
5
+ const relativePath = path.relative(currentDir, targetDir);
6
+ if (relativePath.length === 0) {
7
+ return `Can't use current directory: ${targetDir}`;
8
+ }
9
+ if (relativePath.startsWith("..")) {
10
+ return `Can't use directory outside current directory: ${targetDir}`;
11
+ }
12
+ if (path.isAbsolute(relativePath)) {
13
+ return `Can't use absolute path: ${targetDir}`;
14
+ }
15
+ return true;
16
+ }
@@ -163,8 +163,13 @@ export default async function publishDocs(
163
163
  } else {
164
164
  console.log(`\nCreating a new website for your documentation...`);
165
165
  }
166
- const { appUrl: homeUrl, token: ltToken } = (await deploy(id, paymentLink)) || {};
166
+ const {
167
+ appUrl: homeUrl,
168
+ token: ltToken,
169
+ sessionId: newSessionId,
170
+ } = (await deploy(id, paymentLink)) || {};
167
171
 
172
+ sessionId = newSessionId;
168
173
  appUrl = homeUrl;
169
174
  token = ltToken;
170
175
  } catch (error) {
@@ -174,13 +179,7 @@ export default async function publishDocs(
174
179
  }
175
180
  }
176
181
 
177
- if (sessionId) {
178
- authToken = await getOfficialAccessToken(BASE_URL, false);
179
- client = client || new BrokerClient({ baseUrl: BASE_URL, authToken });
180
-
181
- const { vendors } = await client.getSessionDetail(sessionId, false);
182
- token = vendors?.find((vendor) => vendor.vendorType === "launcher" && vendor.token)?.token;
183
- }
182
+ appUrl = appUrl ?? CLOUD_SERVICE_URL_PROD;
184
183
 
185
184
  console.log(`\nPublishing your documentation to ${chalk.cyan(appUrl)}\n`);
186
185
 
@@ -264,8 +263,10 @@ export default async function publishDocs(
264
263
  await saveValueToConfig("shouldSyncBranding", "", "Should sync branding for documentation");
265
264
  } else {
266
265
  // If the error is 401 or 403, it means the access token is invalid
267
- if (error?.includes("401") || error?.includes("403")) {
266
+ if (error?.includes("401")) {
268
267
  message = `❌ Publishing failed due to an authorization error. Please run ${chalk.cyan("aigne doc clear")} to reset your credentials and try again.`;
268
+ } else if (error?.includes("403")) {
269
+ message = `❌ Publishing failed due to an authorization error. \n - Please confirm you have permission to modify this document [boardId: "${newBoardId || boardId}"]. \n - Or run ${chalk.cyan("aigne doc clear")} to reset your credentials and try again.`;
269
270
  }
270
271
  }
271
272
 
@@ -1,61 +1,67 @@
1
- type: ai
1
+ type: team
2
2
  name: updateDocumentDetail
3
3
  description: Update and optimize document content based on user feedback using diff patches
4
- instructions:
5
- - role: system
6
- url: ../../prompts/detail/update/system-prompt.md
7
- - role: user
8
- url: ../../prompts/detail/update/user-prompt.md
9
- auto_reorder_system_messages: true
10
- auto_merge_system_messages: true
11
- input_schema:
12
- type: object
13
- properties:
14
- originalContent:
15
- type: string
16
- description: Original markdown content to be updated
17
- feedback:
18
- type: string
19
- description: User feedback for content improvements
20
- rules:
21
- type: string
22
- description: User configuration rules
23
- locale:
24
- type: string
25
- description: User language, e.g. zh, en
26
- detailDataSource:
27
- type: string
28
- description: Context for document content
29
- glossary:
30
- type: string
31
- description: Glossary of terms
32
- userPreferences:
33
- type: string
34
- description: User's saved preferences for content and documentation style
35
- targetAudience:
36
- type: string
37
- description: Target audience for the documentation
38
- title:
39
- type: string
40
- description: Document title
41
- description:
42
- type: string
43
- description: Document description
44
- required:
45
- - originalContent
46
- - feedback
47
- output_key: message
48
- afs:
49
- modules:
50
- - module: system-fs
51
- options:
52
- mount: /sources
53
- path: .
54
- description: |
55
- Codebase of the project to be documented used as context for document generation,
56
- should search and read as needed while generating document content
57
- keep_text_in_tool_uses: false
58
- skills:
59
- - ./document-tools/update-document-content.mjs
60
- # - ./generate-diagram.yaml
61
4
  task_render_mode: collapse
5
+ skills:
6
+ - url: ../utils/analyze-feedback-intent.yaml
7
+ - type: ai
8
+ instructions:
9
+ - role: system
10
+ url: ../../prompts/detail/update/system-prompt.md
11
+ - role: user
12
+ url: ../../prompts/detail/update/user-prompt.md
13
+ auto_reorder_system_messages: true
14
+ auto_merge_system_messages: true
15
+ input_schema:
16
+ type: object
17
+ properties:
18
+ originalContent:
19
+ type: string
20
+ description: Original markdown content to be updated
21
+ feedback:
22
+ type: string
23
+ description: User feedback for content improvements
24
+ rules:
25
+ type: string
26
+ description: User configuration rules
27
+ locale:
28
+ type: string
29
+ description: User language, e.g. zh, en
30
+ detailDataSource:
31
+ type: string
32
+ description: Context for document content
33
+ glossary:
34
+ type: string
35
+ description: Glossary of terms
36
+ userPreferences:
37
+ type: string
38
+ description: User's saved preferences for content and documentation style
39
+ targetAudience:
40
+ type: string
41
+ description: Target audience for the documentation
42
+ title:
43
+ type: string
44
+ description: Document title
45
+ description:
46
+ type: string
47
+ description: Document description
48
+ needDataSources:
49
+ type: boolean
50
+ description: Whether data sources are needed for content modifications
51
+ required:
52
+ - originalContent
53
+ - feedback
54
+ output_key: message
55
+ afs:
56
+ modules:
57
+ - module: system-fs
58
+ options:
59
+ mount: /sources
60
+ path: .
61
+ description: |
62
+ Codebase of the project to be documented used as context for document generation,
63
+ should search and read as needed while generating document content
64
+ keep_text_in_tool_uses: false
65
+ skills:
66
+ - ./document-tools/update-document-content.mjs
67
+ # - ./generate-diagram.yaml
@@ -208,13 +208,14 @@ export default async function userReviewDocument({ content, description, ...rest
208
208
 
209
209
  try {
210
210
  // Call updateDocument agent with feedback
211
- await options.context.invoke(updateAgent, {
211
+ const result = await options.context.invoke(updateAgent, {
212
212
  ...rest,
213
213
  originalContent: options.context.userContext.currentContent,
214
214
  feedback: feedback.trim(),
215
215
  userPreferences,
216
216
  title,
217
217
  });
218
+ options.context.userContext.currentContent = result.content;
218
219
 
219
220
  // Check if feedback should be saved as user preference
220
221
  const feedbackRefinerAgent = options.context.agents["checkFeedbackRefiner"];
@@ -0,0 +1,31 @@
1
+ name: analyzeFeedbackIntent
2
+ description: Analyze user feedback to determine if data sources are needed for content modifications
3
+ model:
4
+ reasoning_effort: 200
5
+ task_render_mode: hide
6
+ instructions:
7
+ url: ../../prompts/utils/analyze-feedback-intent.md
8
+ input_schema:
9
+ type: object
10
+ properties:
11
+ feedback:
12
+ type: string
13
+ description: User feedback for content modifications
14
+ required:
15
+ - feedback
16
+ output_schema:
17
+ type: object
18
+ properties:
19
+ needDataSources:
20
+ type: boolean
21
+ description: Whether data sources are needed - true for add/edit operations that need context, false for delete/move/reorder operations
22
+ intentType:
23
+ type: string
24
+ description: The primary type of user intention
25
+ reason:
26
+ type: string
27
+ description: Explanation of why data sources are or aren't needed
28
+ required:
29
+ - needDataSources
30
+ - intentType
31
+ - reason
package/aigne.yaml CHANGED
@@ -76,6 +76,7 @@ agents:
76
76
  - ./agents/utils/find-item-by-path.mjs
77
77
  - ./agents/utils/check-feedback-refiner.mjs
78
78
  - ./agents/utils/feedback-refiner.yaml
79
+ - ./agents/utils/analyze-feedback-intent.yaml
79
80
 
80
81
  # User Preferences & Chat
81
82
  - ./agents/prefs/index.mjs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/doc-smith",
3
- "version": "0.8.15-beta.11",
3
+ "version": "0.8.15-beta.13",
4
4
  "description": "AI-driven documentation generation tool built on the AIGNE Framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,14 +24,14 @@
24
24
  "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
25
25
  "license": "Elastic-2.0",
26
26
  "dependencies": {
27
- "@aigne/aigne-hub": "^0.10.0",
28
- "@aigne/anthropic": "^0.14.0",
29
- "@aigne/cli": "^1.49.1",
30
- "@aigne/core": "^1.61.0",
31
- "@aigne/gemini": "^0.14.0",
32
- "@aigne/openai": "^0.16.0",
27
+ "@aigne/aigne-hub": "^0.10.5-beta.3",
28
+ "@aigne/anthropic": "^0.14.5-beta.3",
29
+ "@aigne/cli": "^1.53.1-beta.4",
30
+ "@aigne/core": "^1.65.1-beta.3",
31
+ "@aigne/gemini": "^0.14.5-beta.3",
32
+ "@aigne/openai": "^0.16.5-beta.3",
33
33
  "@aigne/publish-docs": "^0.12.0",
34
- "@blocklet/payment-broker-client": "^1.21.10",
34
+ "@blocklet/payment-broker-client": "^1.22.7",
35
35
  "@terrastruct/d2": "^0.1.33",
36
36
  "chalk": "^5.5.0",
37
37
  "cli-highlight": "^2.1.11",
@@ -18,6 +18,11 @@ The following are the available enhanced attributes and their descriptions:
18
18
  * `language` and `title` are written directly after \`\`\`, separated by spaces.
19
19
  * Other attributes (`icon`) must be provided in **key=value** format, separated by spaces.
20
20
 
21
+ ### Special Rules
22
+ - If the language is a shell (includes `sh`, `bash`, `zsh`, etc.):
23
+ - Executable shell code blocks must be a single-line command to make copying and running easier.
24
+ - Do not include comments inside executable shell code blocks; place explanatory comments outside the code block.
25
+
21
26
  ### Examples
22
27
 
23
28
  <code_block_good_examples>
@@ -70,9 +75,26 @@ class ShoppingCart {
70
75
  }
71
76
  }
72
77
  ```
78
+
79
+ **Example 5: Shell code block should in one line**
80
+
81
+ ```sh Install aigne deps icon=lucide:terminal
82
+ npm i -g @aigne/cli @aigne/doc-smith @aigne/websmith-smith
83
+ ```
84
+
85
+ **Example 6: Shell code block use `\` to split multiple lines**
86
+ ```bash Deploying with Access Keys icon=lucide:terminal
87
+ blocklet deploy . \
88
+ --endpoint https://my-server.arcblock.io \
89
+ --access-key 'your_access_key_id' \
90
+ --access-secret 'your_access_key_secret' \
91
+ --app-id z2qa9sD2tFAP8gM7C1i8iETg3a1T3A3aT3bQ
92
+ ```
93
+
73
94
  </code_block_good_examples>
74
95
 
75
96
  <code_block_bad_examples>
97
+
76
98
  **Example 1**
77
99
 
78
100
  There are two errors in this example:
@@ -97,5 +119,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
97
119
  }
98
120
  ```
99
121
 
122
+ **Example 2: shell code block have multiple lines**
123
+ ```sh
124
+ npm i -g @aigne/cli
125
+ npm i -g @aigne/doc-smith
126
+ npm i -g @aigne/websmith-smith
127
+ ```
128
+
129
+ **Example 3: shell code block comments**
130
+ ```sh
131
+ # add aigne deps
132
+ npm i -g @aigne/cli
133
+ ```
134
+
100
135
  </code_block_bad_examples>
101
- </enhanced_code_block_rules>
136
+ </enhanced_code_block_rules>
@@ -15,6 +15,7 @@
15
15
  {{originalContent}}
16
16
  </original_page_content>
17
17
 
18
+ {% if needDataSources %}
18
19
  <detail_data_source>
19
20
 
20
21
  {{ detailDataSource }}
@@ -28,6 +29,7 @@
28
29
  {% endif %}
29
30
 
30
31
  </detail_data_source>
32
+ {% endif %}
31
33
 
32
34
  <user_feedback>
33
35
  {{feedback}}
@@ -90,17 +90,4 @@ Analyze the user feedback to determine the intended operation:
90
90
  </operation_output_constraints>
91
91
  </operation_execution_rules>
92
92
 
93
- <file_tool_usage>
94
- 1. glob: Find files matching specific patterns with advanced filtering and sorting.
95
-
96
- 2. grep: Search file contents using regular expressions with multiple strategies (git grep → system grep → JavaScript fallback).
97
-
98
- 3. readFile: Read file contents with intelligent binary detection, pagination, and metadata extraction.
99
-
100
- When to use Tools:
101
- - During document structure update, if the given context is missing or lacks referenced content, use glob/grep/readFile to obtain more context
102
- - When sourceIds or file content from `<file_list>` is needed but not provided in `<data_sources>`, use readFile to read the file content
103
- </file_tool_usage>
104
-
105
-
106
93
  {% include "../../common/document-structure/output-constraints.md" %}
@@ -6,10 +6,11 @@
6
6
  {{allFilesPaths}}
7
7
  </file_list>
8
8
 
9
+ {% if needDataSources %}
9
10
  <data_sources>
10
11
  {{ dataSourceChunk }}
11
12
  </data_sources>
12
-
13
+ {% endif %}
13
14
 
14
15
  Initial Documentation Structure:
15
16
  <initial_document_structure>
@@ -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>
package/utils/deploy.mjs CHANGED
@@ -71,7 +71,7 @@ export async function deploy(id, cachedUrl) {
71
71
  },
72
72
  });
73
73
 
74
- const { appUrl, homeUrl, subscriptionUrl, dashboardUrl, vendors } = result;
74
+ const { appUrl, homeUrl, subscriptionUrl, dashboardUrl, vendors, sessionId } = result;
75
75
  const token = vendors?.[0]?.token;
76
76
 
77
77
  return {
@@ -80,5 +80,6 @@ export async function deploy(id, cachedUrl) {
80
80
  dashboardUrl,
81
81
  subscriptionUrl,
82
82
  token,
83
+ sessionId,
83
84
  };
84
85
  }