@git.zone/tsdoc 1.12.0 → 2.0.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.
@@ -103,7 +103,7 @@ export class Commit {
103
103
  const totalChars = diffStringArray.join('\n\n').length;
104
104
  const estimatedTokens = Math.ceil(totalChars / 4);
105
105
 
106
- console.log(`📊 Raw git diff statistics:`);
106
+ console.log(`Raw git diff statistics:`);
107
107
  console.log(` Files changed: ${diffStringArray.length}`);
108
108
  console.log(` Total characters: ${totalChars.toLocaleString()}`);
109
109
  console.log(` Estimated tokens: ${estimatedTokens.toLocaleString()}`);
@@ -111,7 +111,7 @@ export class Commit {
111
111
 
112
112
  // Calculate available tokens for diff based on total budget
113
113
  const maxDiffTokens = calculateMaxDiffTokens();
114
- console.log(`📊 Token budget: ${maxDiffTokens.toLocaleString()} tokens for diff (limit: ${TOKEN_BUDGET.OPENAI_CONTEXT_LIMIT.toLocaleString()}, overhead: ${(TOKEN_BUDGET.SMARTAGENT_OVERHEAD + TOKEN_BUDGET.TASK_PROMPT_OVERHEAD).toLocaleString()})`);
114
+ console.log(`Token budget: ${maxDiffTokens.toLocaleString()} tokens for diff (limit: ${TOKEN_BUDGET.OPENAI_CONTEXT_LIMIT.toLocaleString()}, overhead: ${(TOKEN_BUDGET.SMARTAGENT_OVERHEAD + TOKEN_BUDGET.TASK_PROMPT_OVERHEAD).toLocaleString()})`);
115
115
 
116
116
  // Use DiffProcessor to intelligently handle large diffs
117
117
  const diffProcessor = new DiffProcessor({
@@ -125,14 +125,14 @@ export class Commit {
125
125
  const processedDiff = diffProcessor.processDiffs(diffStringArray);
126
126
  processedDiffString = diffProcessor.formatForContext(processedDiff);
127
127
 
128
- console.log(`📝 Processed diff statistics:`);
128
+ console.log(`Processed diff statistics:`);
129
129
  console.log(` Full diffs: ${processedDiff.fullDiffs.length} files`);
130
130
  console.log(` Summarized: ${processedDiff.summarizedDiffs.length} files`);
131
131
  console.log(` Metadata only: ${processedDiff.metadataOnly.length} files`);
132
132
  console.log(` Final tokens: ${processedDiff.totalTokens.toLocaleString()}`);
133
133
 
134
134
  if (estimatedTokens > 50000) {
135
- console.log(`✅ DiffProcessor reduced token usage: ${estimatedTokens.toLocaleString()} ${processedDiff.totalTokens.toLocaleString()}`);
135
+ console.log(`DiffProcessor reduced token usage: ${estimatedTokens.toLocaleString()} -> ${processedDiff.totalTokens.toLocaleString()}`);
136
136
  }
137
137
 
138
138
  // Validate total tokens won't exceed limit
@@ -141,71 +141,44 @@ export class Commit {
141
141
  + TOKEN_BUDGET.TASK_PROMPT_OVERHEAD;
142
142
 
143
143
  if (totalEstimatedTokens > TOKEN_BUDGET.OPENAI_CONTEXT_LIMIT - TOKEN_BUDGET.SAFETY_MARGIN) {
144
- console.log(`⚠️ Warning: Estimated tokens (${totalEstimatedTokens.toLocaleString()}) approaching limit`);
144
+ console.log(`Warning: Estimated tokens (${totalEstimatedTokens.toLocaleString()}) approaching limit`);
145
145
  console.log(` Consider splitting into smaller commits`);
146
146
  }
147
147
  } else {
148
148
  processedDiffString = 'No changes.';
149
149
  }
150
150
 
151
- // Use DualAgentOrchestrator for commit message generation
152
- const commitOrchestrator = new plugins.smartagent.DualAgentOrchestrator({
153
- smartAiInstance: this.aiDocsRef.smartAiInstance,
154
- defaultProvider: 'openai',
155
- logPrefix: '[Commit]',
156
- onProgress: (event) => logger.log(event.logLevel, event.logMessage),
157
- guardianPolicyPrompt: `
158
- You validate commit messages for semantic versioning compliance.
159
-
160
- APPROVE tool calls for:
161
- - Reading package.json or source files to understand project context
162
- - Using tree to see project structure
163
- - Listing directory contents
164
-
165
- REJECT tool calls for:
166
- - Reading files outside the project directory
167
- - Writing, deleting, or modifying any files
168
- - Any destructive operations
169
-
170
- APPROVE final output if:
171
- - Version level (fix/feat/BREAKING CHANGE) matches the scope of changes in the diff
172
- - Commit message is clear, professional, and follows conventional commit conventions
173
- - No personal information, licensing details, or AI mentions (Claude/Codex) included
174
- - JSON structure is valid with all required fields
175
- - Scope accurately reflects the changed modules/files
176
-
177
- REJECT final output if:
178
- - Version level doesn't match the scope of changes (e.g., "feat" for a typo fix should be "fix")
179
- - Message is vague, unprofessional, or contains sensitive information
180
- - JSON is malformed or missing required fields
181
- `,
182
- });
151
+ // Use runAgent for commit message generation with filesystem tool
152
+ const fsTools = plugins.smartagentTools.filesystemTool({ rootDir: this.projectDir });
183
153
 
184
- // Register scoped filesystem tool for agent exploration
185
- commitOrchestrator.registerScopedFilesystemTool(this.projectDir, [
186
- '.nogit/**',
187
- 'node_modules/**',
188
- '.git/**',
189
- 'dist/**',
190
- 'dist_*/**',
191
- ]);
154
+ const commitSystemPrompt = `
155
+ You create commit messages for git commits following semantic versioning conventions.
156
+
157
+ You have access to filesystem tools to explore the project if needed.
192
158
 
193
- await commitOrchestrator.start();
159
+ IMPORTANT RULES:
160
+ - Only READ files (package.json, source files) for context
161
+ - Do NOT write, delete, or modify any files
162
+ - Version level (fix/feat/BREAKING CHANGE) must match the scope of changes
163
+ - Commit message must be clear, professional, and follow conventional commit conventions
164
+ - Do NOT include personal information, licensing details, or AI mentions (Claude/Codex)
165
+ - JSON structure must be valid with all required fields
166
+ - Scope must accurately reflect the changed modules/files
167
+ `;
194
168
 
195
169
  const commitTaskPrompt = `
196
- You create a commit message for a git commit.
197
170
  Project directory: ${this.projectDir}
198
171
 
199
- You have access to a filesystem tool to explore the project if needed:
200
- - Use tree to see project structure
201
- - Use read to read package.json or source files for context
172
+ You have access to filesystem tools to explore the project if needed:
173
+ - Use list_directory to see project structure
174
+ - Use read_file to read package.json or source files for context
202
175
 
203
176
  Analyze the git diff below to understand what changed and generate a commit message.
204
177
 
205
178
  You should not include any licensing information or personal information.
206
179
  Never mention CLAUDE code, or codex.
207
180
 
208
- Your final output (inside the task_complete tags) must be ONLY valid JSON - the raw JSON object, nothing else.
181
+ Your final response must be ONLY valid JSON - the raw JSON object, nothing else.
209
182
  No explanations, no summaries, no markdown - just the JSON object that can be parsed with JSON.parse().
210
183
 
211
184
  Here is the structure of the JSON you must return:
@@ -227,15 +200,19 @@ ${processedDiffString}
227
200
  Analyze these changes and output the JSON commit message object.
228
201
  `;
229
202
 
230
- const commitResult = await commitOrchestrator.run(commitTaskPrompt);
231
- await commitOrchestrator.stop();
203
+ logger.log('info', 'Starting commit message generation with agent...');
232
204
 
233
- if (!commitResult.success) {
234
- throw new Error(`Commit message generation failed: ${commitResult.status}`);
235
- }
205
+ const commitResult = await plugins.smartagent.runAgent({
206
+ model: this.aiDocsRef.model,
207
+ prompt: commitTaskPrompt,
208
+ system: commitSystemPrompt,
209
+ tools: fsTools,
210
+ maxSteps: 10,
211
+ onToolCall: (toolName) => logger.log('info', `[Commit] Tool call: ${toolName}`),
212
+ });
236
213
 
237
214
  // Extract JSON from result - handle cases where AI adds text around it
238
- let jsonString = commitResult.result
215
+ let jsonString = commitResult.text
239
216
  .replace(/```json\n?/gi, '')
240
217
  .replace(/```\n?/gi, '');
241
218
 
@@ -259,30 +236,16 @@ Analyze these changes and output the JSON commit message object.
259
236
  const commitMessages = await gitRepo.getAllCommitMessages();
260
237
  console.log(JSON.stringify(commitMessages, null, 2));
261
238
 
262
- // Use DualAgentOrchestrator for changelog generation with Guardian validation
263
- const changelogOrchestrator = new plugins.smartagent.DualAgentOrchestrator({
264
- smartAiInstance: this.aiDocsRef.smartAiInstance,
265
- defaultProvider: 'openai',
266
- logPrefix: '[Changelog]',
267
- onProgress: (event) => logger.log(event.logLevel, event.logMessage),
268
- guardianPolicyPrompt: `
269
- You validate changelog generation.
270
-
271
- APPROVE if:
272
- - Changelog follows proper markdown format with ## headers for each version
273
- - Entries are chronologically ordered (newest first)
274
- - Version ranges for trivial commits are properly summarized
275
- - No duplicate or empty entries
276
- - Format matches: ## yyyy-mm-dd - x.x.x - scope
239
+ const changelogSystemPrompt = `
240
+ You generate changelog.md files for software projects.
277
241
 
278
- REJECT with feedback if:
279
- - Markdown formatting is incorrect
280
- - Entries are not meaningful or helpful
281
- - Dates or versions are malformed
282
- `,
283
- });
284
-
285
- await changelogOrchestrator.start();
242
+ RULES:
243
+ - Changelog must follow proper markdown format with ## headers for each version
244
+ - Entries must be chronologically ordered (newest first)
245
+ - Version ranges for trivial commits should be properly summarized
246
+ - No duplicate or empty entries
247
+ - Format: ## yyyy-mm-dd - x.x.x - scope
248
+ `;
286
249
 
287
250
  const changelogTaskPrompt = `
288
251
  You are building a changelog.md file for the project.
@@ -291,7 +254,7 @@ Omit commits and versions that lack relevant changes, but make sure to mention t
291
254
  A changelog entry should look like this:
292
255
 
293
256
  ## yyyy-mm-dd - x.x.x - scope here
294
- main descriptiom here
257
+ main description here
295
258
 
296
259
  - detailed bullet points follow
297
260
 
@@ -305,16 +268,17 @@ Here are the commit messages:
305
268
  ${JSON.stringify(commitMessages, null, 2)}
306
269
  `;
307
270
 
308
- const changelogResult = await changelogOrchestrator.run(changelogTaskPrompt);
309
- await changelogOrchestrator.stop();
310
-
311
- if (!changelogResult.success) {
312
- throw new Error(`Changelog generation failed: ${changelogResult.status}`);
313
- }
271
+ const changelogResult = await plugins.smartagent.runAgent({
272
+ model: this.aiDocsRef.model,
273
+ prompt: changelogTaskPrompt,
274
+ system: changelogSystemPrompt,
275
+ maxSteps: 1,
276
+ onToolCall: (toolName) => logger.log('info', `[Changelog] Tool call: ${toolName}`),
277
+ });
314
278
 
315
279
  previousChangelog = plugins.smartfileFactory.fromString(
316
280
  previousChangelogPath,
317
- changelogResult.result.replaceAll('```markdown', '').replaceAll('```', ''),
281
+ changelogResult.text.replaceAll('```markdown', '').replaceAll('```', ''),
318
282
  'utf8'
319
283
  );
320
284
  }
@@ -19,53 +19,29 @@ export class Description {
19
19
  }
20
20
 
21
21
  public async build() {
22
- // Use DualAgentOrchestrator with filesystem tool for agent-driven exploration
23
- const descriptionOrchestrator = new plugins.smartagent.DualAgentOrchestrator({
24
- smartAiInstance: this.aiDocsRef.smartAiInstance,
25
- defaultProvider: 'openai',
26
- maxIterations: 15,
27
- maxResultChars: 10000, // Limit tool output to prevent token explosion
28
- maxHistoryMessages: 15, // Limit history window
29
- logPrefix: '[Description]',
30
- onProgress: (event) => logger.log(event.logLevel, event.logMessage),
31
- guardianPolicyPrompt: `
32
- You validate description generation tool calls and outputs.
33
-
34
- APPROVE tool calls for:
35
- - Reading package.json, npmextra.json, or source files in the ts/ directory
36
- - Listing directory contents to understand project structure
37
- - Using tree to see project structure
38
-
39
- REJECT tool calls for:
40
- - Reading files outside the project directory
41
- - Writing, deleting, or modifying any files
42
- - Any destructive operations
43
-
44
- For final output, APPROVE if:
45
- - JSON is valid and parseable
46
- - Description is a clear, concise one-sentence summary
47
- - Keywords are relevant to the project's use cases
48
- - Both description and keywords fields are present
49
-
50
- REJECT final output if:
51
- - JSON is malformed or wrapped in markdown code blocks
52
- - Description is too long or vague
53
- - Keywords are irrelevant or generic
54
- `,
55
- });
56
-
57
- // Register scoped filesystem tool for agent exploration
58
- descriptionOrchestrator.registerScopedFilesystemTool(this.projectDir);
59
-
60
- await descriptionOrchestrator.start();
22
+ // Use runAgent with filesystem tool for agent-driven exploration
23
+ const fsTools = plugins.smartagentTools.filesystemTool({ rootDir: this.projectDir });
24
+
25
+ const descriptionSystemPrompt = `
26
+ You create project descriptions and keywords for npm packages.
27
+
28
+ You have access to filesystem tools to explore the project.
29
+
30
+ IMPORTANT RULES:
31
+ - Only READ files (package.json, npmextra.json, source files in ts/)
32
+ - Do NOT write, delete, or modify any files
33
+ - Your final response must be valid JSON only
34
+ - Description must be a clear, concise one-sentence summary
35
+ - Keywords must be relevant to the project's use cases
36
+ - Both description and keywords fields must be present
37
+ - Do NOT wrap JSON in markdown code blocks
38
+ `;
61
39
 
62
40
  const descriptionTaskPrompt = `
63
- You create a project description and keywords for an npm package.
64
-
65
41
  PROJECT DIRECTORY: ${this.projectDir}
66
42
 
67
- Use the filesystem tool to explore the project and understand what it does:
68
- 1. First, use tree to see the project structure
43
+ Use the filesystem tools to explore the project and understand what it does:
44
+ 1. First, use list_directory to see the project structure
69
45
  2. Read package.json to understand the package name and current description
70
46
  3. Read npmextra.json if it exists for additional metadata
71
47
  4. Read key source files in ts/ directory to understand the implementation
@@ -83,31 +59,35 @@ Your answer should be parseable with JSON.parse() without modifying anything.
83
59
  Don't wrap the JSON in \`\`\`json\`\`\` - just return the raw JSON object.
84
60
  `;
85
61
 
86
- const descriptionResult = await descriptionOrchestrator.run(descriptionTaskPrompt);
87
- await descriptionOrchestrator.stop();
62
+ logger.log('info', 'Starting description generation with agent...');
88
63
 
89
- if (!descriptionResult.success) {
90
- throw new Error(`Description generation failed: ${descriptionResult.status}`);
91
- }
64
+ const descriptionResult = await plugins.smartagent.runAgent({
65
+ model: this.aiDocsRef.model,
66
+ prompt: descriptionTaskPrompt,
67
+ system: descriptionSystemPrompt,
68
+ tools: fsTools,
69
+ maxSteps: 15,
70
+ onToolCall: (toolName) => logger.log('info', `[Description] Tool call: ${toolName}`),
71
+ });
92
72
 
93
- console.log(descriptionResult.result);
73
+ console.log(descriptionResult.text);
94
74
  const resultObject: IDescriptionInterface = JSON.parse(
95
- descriptionResult.result.replace('```json', '').replace('```', ''),
75
+ descriptionResult.text.replace('```json', '').replace('```', ''),
96
76
  );
97
77
 
98
78
  // Use ProjectContext to get file handles for writing
99
79
  const projectContext = new ProjectContext(this.projectDir);
100
80
  const files = await projectContext.gatherFiles();
101
81
 
102
- // Update npmextra.json
103
- const npmextraJson = files.smartfilesNpmextraJSON;
104
- const npmextraJsonContent = JSON.parse(npmextraJson.contents.toString());
82
+ // Update smartconfig.json
83
+ const smartconfigJson = files.smartfilesNpmextraJSON;
84
+ const smartconfigJsonContent = JSON.parse(smartconfigJson.contents.toString());
105
85
 
106
- npmextraJsonContent['@git.zone/cli'].module.description = resultObject.description;
107
- npmextraJsonContent['@git.zone/cli'].module.keywords = resultObject.keywords;
86
+ smartconfigJsonContent['@git.zone/cli'].module.description = resultObject.description;
87
+ smartconfigJsonContent['@git.zone/cli'].module.keywords = resultObject.keywords;
108
88
 
109
- npmextraJson.contents = Buffer.from(JSON.stringify(npmextraJsonContent, null, 2));
110
- await npmextraJson.write();
89
+ smartconfigJson.contents = Buffer.from(JSON.stringify(smartconfigJsonContent, null, 2));
90
+ await smartconfigJson.write();
111
91
 
112
92
  // Update package.json
113
93
  const packageJson = files.smartfilePackageJSON;
@@ -120,6 +100,6 @@ Don't wrap the JSON in \`\`\`json\`\`\` - just return the raw JSON object.
120
100
  console.log(`\n======================\n`);
121
101
  console.log(JSON.stringify(resultObject, null, 2));
122
102
  console.log(`\n======================\n`);
123
- return descriptionResult.result;
103
+ return descriptionResult.text;
124
104
  }
125
105
  }
@@ -27,7 +27,7 @@ export class ProjectContext {
27
27
  this.projectDir,
28
28
  );
29
29
  const smartfilesNpmextraJSON = await plugins.smartfileFactory.fromFilePath(
30
- plugins.path.join(this.projectDir, 'npmextra.json'),
30
+ plugins.path.join(this.projectDir, 'smartconfig.json'),
31
31
  this.projectDir,
32
32
  );
33
33
  const smartfilesMod = await plugins.smartfileFactory.virtualDirectoryFromPath(
@@ -19,64 +19,40 @@ export class Readme {
19
19
 
20
20
  // First check legal info before introducing any cost
21
21
  const projectContext = new ProjectContext(this.projectDir);
22
- const npmExtraJson = JSON.parse(
22
+ const smartconfigJson = JSON.parse(
23
23
  (await projectContext.gatherFiles()).smartfilesNpmextraJSON.contents.toString()
24
24
  );
25
- const legalInfo = npmExtraJson?.['@git.zone/tsdoc']?.legal;
25
+ const legalInfo = smartconfigJson?.['@git.zone/tsdoc']?.legal;
26
26
  if (!legalInfo) {
27
- const error = new Error(`No legal information found in npmextra.json`);
27
+ const error = new Error(`No legal information found in smartconfig.json`);
28
28
  console.log(error);
29
29
  }
30
30
 
31
- // Use DualAgentOrchestrator with filesystem tool for agent-driven exploration
32
- const readmeOrchestrator = new plugins.smartagent.DualAgentOrchestrator({
33
- smartAiInstance: this.aiDocsRef.smartAiInstance,
34
- defaultProvider: 'openai',
35
- maxIterations: 25,
36
- maxResultChars: 15000, // Limit tool output to prevent token explosion
37
- maxHistoryMessages: 20, // Limit history window
38
- logPrefix: '[README]',
39
- onProgress: (event) => logger.log(event.logLevel, event.logMessage),
40
- guardianPolicyPrompt: `
41
- You validate README generation tool calls and outputs.
42
-
43
- APPROVE tool calls for:
44
- - Reading any files within the project directory (package.json, ts/*.ts, readme.md, etc.)
45
- - Using tree to see project structure
46
- - Using glob to find source files
47
- - Listing directory contents
48
-
49
- REJECT tool calls for:
50
- - Reading files outside the project directory
51
- - Writing, deleting, or modifying any files
52
- - Any destructive operations
53
-
54
- For final README output, APPROVE if:
55
- - README follows proper markdown format
56
- - Contains Install and Usage sections
57
- - Code examples are correct TypeScript/ESM syntax
58
- - Documentation is comprehensive and helpful
59
-
60
- REJECT final output if:
61
- - README is incomplete or poorly formatted
62
- - Contains licensing information (added separately)
63
- - Uses CommonJS syntax instead of ESM
64
- - Contains "in conclusion" or similar filler
65
- `,
66
- });
31
+ // Use runAgent with filesystem tool for agent-driven exploration
32
+ const fsTools = plugins.smartagentTools.filesystemTool({ rootDir: this.projectDir });
67
33
 
68
- // Register scoped filesystem tool for agent exploration
69
- readmeOrchestrator.registerScopedFilesystemTool(this.projectDir);
34
+ const readmeSystemPrompt = `
35
+ You create markdown READMEs for npm projects. You only output the markdown readme.
70
36
 
71
- await readmeOrchestrator.start();
37
+ You have access to filesystem tools to explore the project. Use them to understand the codebase.
38
+
39
+ IMPORTANT RULES:
40
+ - Only READ files within the project directory
41
+ - Do NOT write, delete, or modify any files
42
+ - README must follow proper markdown format
43
+ - Must contain Install and Usage sections
44
+ - Code examples must use correct TypeScript/ESM syntax
45
+ - Documentation must be comprehensive and helpful
46
+ - Do NOT include licensing information (added separately)
47
+ - Do NOT use CommonJS syntax - only ESM
48
+ - Do NOT include "in conclusion" or similar filler
49
+ `;
72
50
 
73
51
  const readmeTaskPrompt = `
74
- You create markdown READMEs for npm projects. You only output the markdown readme.
75
-
76
52
  PROJECT DIRECTORY: ${this.projectDir}
77
53
 
78
- Use the filesystem tool to explore the project and understand what it does:
79
- 1. First, use tree to see the project structure (maxDepth: 3)
54
+ Use the filesystem tools to explore the project and understand what it does:
55
+ 1. First, use list_directory to see the project structure
80
56
  2. Read package.json to understand the package name, description, and dependencies
81
57
  3. Read the existing readme.md if it exists (use it as a base, improve and expand)
82
58
  4. Read readme.hints.md if it exists (contains hints for documentation)
@@ -106,15 +82,19 @@ Then generate a comprehensive README following this template:
106
82
  ]
107
83
  `;
108
84
 
109
- const readmeResult = await readmeOrchestrator.run(readmeTaskPrompt);
110
- await readmeOrchestrator.stop();
85
+ logger.log('info', 'Starting README generation with agent...');
111
86
 
112
- if (!readmeResult.success) {
113
- throw new Error(`README generation failed: ${readmeResult.status}`);
114
- }
87
+ const readmeResult = await plugins.smartagent.runAgent({
88
+ model: this.aiDocsRef.model,
89
+ prompt: readmeTaskPrompt,
90
+ system: readmeSystemPrompt,
91
+ tools: fsTools,
92
+ maxSteps: 25,
93
+ onToolCall: (toolName) => logger.log('info', `[README] Tool call: ${toolName}`),
94
+ });
115
95
 
116
96
  // Clean up markdown formatting if wrapped in code blocks
117
- let resultMessage = readmeResult.result
97
+ let resultMessage = readmeResult.text
118
98
  .replace(/^```markdown\n?/i, '')
119
99
  .replace(/\n?```$/i, '');
120
100
 
@@ -142,40 +122,19 @@ Then generate a comprehensive README following this template:
142
122
  .encoding('utf8')
143
123
  .read();
144
124
 
145
- // Create a new orchestrator with filesystem tool for each submodule
146
- const subModuleOrchestrator = new plugins.smartagent.DualAgentOrchestrator({
147
- smartAiInstance: this.aiDocsRef.smartAiInstance,
148
- defaultProvider: 'openai',
149
- maxIterations: 20,
150
- maxResultChars: 12000,
151
- maxHistoryMessages: 15,
152
- logPrefix: `[README:${subModule}]`,
153
- onProgress: (event) => logger.log(event.logLevel, event.logMessage),
154
- guardianPolicyPrompt: `
155
- You validate README generation for submodules.
156
-
157
- APPROVE tool calls for:
158
- - Reading any files within the submodule directory
159
- - Using tree to see structure
160
- - Using glob to find source files
161
-
162
- REJECT tool calls for:
163
- - Reading files outside the submodule directory
164
- - Writing, deleting, or modifying any files
165
- - Any destructive operations
166
-
167
- APPROVE final README if comprehensive, well-formatted markdown with ESM TypeScript examples.
168
- REJECT incomplete READMEs or those with licensing info.
169
- `,
170
- });
125
+ const subModuleFsTools = plugins.smartagentTools.filesystemTool({ rootDir: subModulePath });
171
126
 
172
- // Register scoped filesystem tool for the submodule directory
173
- subModuleOrchestrator.registerScopedFilesystemTool(subModulePath);
127
+ const subModuleSystemPrompt = `
128
+ You create markdown READMEs for npm projects. You only output the markdown readme.
174
129
 
175
- await subModuleOrchestrator.start();
130
+ IMPORTANT RULES:
131
+ - Only READ files within the submodule directory
132
+ - Do NOT write, delete, or modify any files
133
+ - README must be comprehensive, well-formatted markdown with ESM TypeScript examples
134
+ - Do NOT include licensing information (added separately)
135
+ `;
176
136
 
177
137
  const subModulePrompt = `
178
- You create markdown READMEs for npm projects. You only output the markdown readme.
179
138
  SUB MODULE: ${subModule}
180
139
  SUB MODULE DIRECTORY: ${subModulePath}
181
140
 
@@ -183,8 +142,8 @@ IMPORTANT: YOU ARE CREATING THE README FOR THIS SUB MODULE: ${subModule}
183
142
  The Sub Module will be published with:
184
143
  ${JSON.stringify(tspublishData, null, 2)}
185
144
 
186
- Use the filesystem tool to explore the submodule:
187
- 1. Use tree to see the submodule structure
145
+ Use the filesystem tools to explore the submodule:
146
+ 1. Use list_directory to see the submodule structure
188
147
  2. Read package.json to understand the submodule
189
148
  3. Read source files in ts/ directory to understand the implementation
190
149
 
@@ -208,21 +167,23 @@ Generate a README following the template:
208
167
  Don't use \`\`\` at the beginning or end. Only for code blocks.
209
168
  `;
210
169
 
211
- const subModuleResult = await subModuleOrchestrator.run(subModulePrompt);
212
- await subModuleOrchestrator.stop();
213
-
214
- if (subModuleResult.success) {
215
- const subModuleReadmeString = subModuleResult.result
216
- .replace(/^```markdown\n?/i, '')
217
- .replace(/\n?```$/i, '') + '\n' + legalInfo;
218
- await plugins.fsInstance
219
- .file(plugins.path.join(subModulePath, 'readme.md'))
220
- .encoding('utf8')
221
- .write(subModuleReadmeString);
222
- logger.log('success', `Built readme for ${subModule}`);
223
- } else {
224
- logger.log('error', `Failed to build readme for ${subModule}: ${subModuleResult.status}`);
225
- }
170
+ const subModuleResult = await plugins.smartagent.runAgent({
171
+ model: this.aiDocsRef.model,
172
+ prompt: subModulePrompt,
173
+ system: subModuleSystemPrompt,
174
+ tools: subModuleFsTools,
175
+ maxSteps: 20,
176
+ onToolCall: (toolName) => logger.log('info', `[README:${subModule}] Tool call: ${toolName}`),
177
+ });
178
+
179
+ const subModuleReadmeString = subModuleResult.text
180
+ .replace(/^```markdown\n?/i, '')
181
+ .replace(/\n?```$/i, '') + '\n' + legalInfo;
182
+ await plugins.fsInstance
183
+ .file(plugins.path.join(subModulePath, 'readme.md'))
184
+ .encoding('utf8')
185
+ .write(subModuleReadmeString);
186
+ logger.log('success', `Built readme for ${subModule}`);
226
187
  }
227
188
 
228
189
  return resultMessage;