@git.zone/tsdoc 1.6.1 → 1.8.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@git.zone/tsdoc",
3
- "version": "1.6.1",
3
+ "version": "1.8.0",
4
4
  "private": false,
5
5
  "description": "A comprehensive TypeScript documentation tool that leverages AI to generate and enhance project documentation, including dynamic README creation, API docs via TypeDoc, and smart commit message generation.",
6
6
  "type": "module",
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/tsdoc',
6
- version: '1.6.1',
6
+ version: '1.8.0',
7
7
  description: 'A comprehensive TypeScript documentation tool that leverages AI to generate and enhance project documentation, including dynamic README creation, API docs via TypeDoc, and smart commit message generation.'
8
8
  }
@@ -32,7 +32,10 @@ export class Commit {
32
32
  'package-lock.json',
33
33
  ]);
34
34
  // Use the new TaskContextFactory for optimized context
35
- const taskContextFactory = new (await import('../context/index.js')).TaskContextFactory(this.projectDir);
35
+ const taskContextFactory = new (await import('../context/index.js')).TaskContextFactory(
36
+ this.projectDir,
37
+ this.aiDocsRef.openaiInstance
38
+ );
36
39
  await taskContextFactory.initialize();
37
40
 
38
41
  // Generate context specifically for commit task
@@ -19,7 +19,10 @@ export class Description {
19
19
 
20
20
  public async build() {
21
21
  // Use the new TaskContextFactory for optimized context
22
- const taskContextFactory = new (await import('../context/index.js')).TaskContextFactory(this.projectDir);
22
+ const taskContextFactory = new (await import('../context/index.js')).TaskContextFactory(
23
+ this.projectDir,
24
+ this.aiDocsRef.openaiInstance
25
+ );
23
26
  await taskContextFactory.initialize();
24
27
 
25
28
  // Generate context specifically for description task
@@ -18,7 +18,10 @@ export class Readme {
18
18
  let finalReadmeString = ``;
19
19
 
20
20
  // Use the new TaskContextFactory for optimized context
21
- const taskContextFactory = new (await import('../context/index.js')).TaskContextFactory(this.projectDir);
21
+ const taskContextFactory = new (await import('../context/index.js')).TaskContextFactory(
22
+ this.projectDir,
23
+ this.aiDocsRef.openaiInstance
24
+ );
22
25
  await taskContextFactory.initialize();
23
26
 
24
27
  // Generate context specifically for readme task
package/ts/cli.ts CHANGED
@@ -31,18 +31,18 @@ export const run = async () => {
31
31
  tsdocCli.addCommand('aidoc').subscribe(async (argvArg) => {
32
32
  const aidocInstance = new AiDoc();
33
33
  await aidocInstance.start();
34
-
34
+
35
35
  // Get context token count if requested
36
36
  if (argvArg.tokens || argvArg.showTokens) {
37
37
  logger.log('info', `Calculating context token count...`);
38
38
  const tokenCount = await aidocInstance.getProjectContextTokenCount(paths.cwd);
39
39
  logger.log('ok', `Total context token count: ${tokenCount}`);
40
-
40
+
41
41
  if (argvArg.tokensOnly) {
42
42
  return; // Exit early if we only want token count
43
43
  }
44
44
  }
45
-
45
+
46
46
  logger.log('info', `Generating new readme...`);
47
47
  logger.log('info', `This may take some time...`);
48
48
  await aidocInstance.buildReadme(paths.cwd);
@@ -54,67 +54,50 @@ export const run = async () => {
54
54
  tsdocCli.addCommand('tokens').subscribe(async (argvArg) => {
55
55
  const aidocInstance = new AiDoc();
56
56
  await aidocInstance.start();
57
-
57
+
58
58
  logger.log('info', `Calculating context token count...`);
59
-
60
- // Determine context mode based on args
61
- let contextMode: context.ContextMode = 'full';
62
- if (argvArg.trim || argvArg.trimmed) {
63
- contextMode = 'trimmed';
64
- } else if (argvArg.summarize || argvArg.summarized) {
65
- contextMode = 'summarized';
66
- }
67
-
59
+
68
60
  // Get task type if specified
69
61
  let taskType: context.TaskType | undefined = undefined;
70
62
  if (argvArg.task) {
71
63
  if (['readme', 'commit', 'description'].includes(argvArg.task)) {
72
64
  taskType = argvArg.task as context.TaskType;
73
65
  } else {
74
- logger.log('warn', `Unknown task type: ${argvArg.task}. Using default context.`);
66
+ logger.log('warn', `Unknown task type: ${argvArg.task}. Using default (readme).`);
67
+ taskType = 'readme';
75
68
  }
69
+ } else {
70
+ // Default to readme if no task specified
71
+ taskType = 'readme';
76
72
  }
77
-
78
- // Use enhanced context
73
+
74
+ // Use iterative context building
79
75
  const taskFactory = new context.TaskContextFactory(paths.cwd);
80
76
  await taskFactory.initialize();
81
-
82
- let contextResult: context.IContextResult;
83
-
77
+
78
+ let contextResult: context.IIterativeContextResult;
79
+
84
80
  if (argvArg.all) {
85
81
  // Show stats for all task types
86
82
  const stats = await taskFactory.getTokenStats();
87
-
83
+
88
84
  logger.log('ok', 'Token statistics by task:');
89
85
  for (const [task, data] of Object.entries(stats)) {
90
86
  logger.log('info', `\n${task.toUpperCase()}:`);
91
87
  logger.log('info', ` Tokens: ${data.tokenCount}`);
92
88
  logger.log('info', ` Token savings: ${data.savings}`);
93
89
  logger.log('info', ` Files: ${data.includedFiles} included, ${data.trimmedFiles} trimmed, ${data.excludedFiles} excluded`);
94
-
90
+
95
91
  // Calculate percentage of model context
96
92
  const o4MiniPercentage = (data.tokenCount / 200000 * 100).toFixed(2);
97
93
  logger.log('info', ` Context usage: ${o4MiniPercentage}% of o4-mini (200K tokens)`);
98
94
  }
99
-
95
+
100
96
  return;
101
97
  }
102
-
103
- if (taskType) {
104
- // Get context for specific task
105
- contextResult = await taskFactory.createContextForTask(taskType);
106
- } else {
107
- // Get generic context with specified mode
108
- const enhancedContext = new context.EnhancedContext(paths.cwd);
109
- await enhancedContext.initialize();
110
- enhancedContext.setContextMode(contextMode);
111
-
112
- if (argvArg.maxTokens) {
113
- enhancedContext.setTokenBudget(parseInt(argvArg.maxTokens, 10));
114
- }
115
-
116
- contextResult = await enhancedContext.buildContext();
117
- }
98
+
99
+ // Get context for specific task
100
+ contextResult = await taskFactory.createContextForTask(taskType);
118
101
 
119
102
  // Display results
120
103
  logger.log('ok', `Total context token count: ${contextResult.tokenCount}`);
@@ -9,7 +9,8 @@ import type {
9
9
  ICacheConfig,
10
10
  IAnalyzerConfig,
11
11
  IPrioritizationWeights,
12
- ITierConfig
12
+ ITierConfig,
13
+ IIterativeConfig
13
14
  } from './types.js';
14
15
 
15
16
  /**
@@ -98,6 +99,13 @@ export class ConfigManager {
98
99
  essential: { minScore: 0.8, trimLevel: 'none' },
99
100
  important: { minScore: 0.5, trimLevel: 'light' },
100
101
  optional: { minScore: 0.2, trimLevel: 'aggressive' }
102
+ },
103
+ iterative: {
104
+ maxIterations: 5,
105
+ firstPassFileLimit: 10,
106
+ subsequentPassFileLimit: 5,
107
+ temperature: 0.3,
108
+ model: 'gpt-4-turbo-preview'
101
109
  }
102
110
  };
103
111
  }
@@ -156,15 +164,15 @@ export class ConfigManager {
156
164
  */
157
165
  private mergeConfigs(defaultConfig: IContextConfig, userConfig: Partial<IContextConfig>): IContextConfig {
158
166
  const result: IContextConfig = { ...defaultConfig };
159
-
167
+
160
168
  // Merge top-level properties
161
169
  if (userConfig.maxTokens !== undefined) result.maxTokens = userConfig.maxTokens;
162
170
  if (userConfig.defaultMode !== undefined) result.defaultMode = userConfig.defaultMode;
163
-
171
+
164
172
  // Merge task-specific settings
165
173
  if (userConfig.taskSpecificSettings) {
166
174
  result.taskSpecificSettings = result.taskSpecificSettings || {};
167
-
175
+
168
176
  // For each task type, merge settings
169
177
  (['readme', 'commit', 'description'] as TaskType[]).forEach(taskType => {
170
178
  if (userConfig.taskSpecificSettings?.[taskType]) {
@@ -175,7 +183,7 @@ export class ConfigManager {
175
183
  }
176
184
  });
177
185
  }
178
-
186
+
179
187
  // Merge trimming configuration
180
188
  if (userConfig.trimming) {
181
189
  result.trimming = {
@@ -216,6 +224,14 @@ export class ConfigManager {
216
224
  };
217
225
  }
218
226
 
227
+ // Merge iterative configuration
228
+ if (userConfig.iterative) {
229
+ result.iterative = {
230
+ ...result.iterative,
231
+ ...userConfig.iterative
232
+ };
233
+ }
234
+
219
235
  return result;
220
236
  }
221
237
 
@@ -331,6 +347,19 @@ export class ConfigManager {
331
347
  };
332
348
  }
333
349
 
350
+ /**
351
+ * Get iterative configuration
352
+ */
353
+ public getIterativeConfig(): IIterativeConfig {
354
+ return this.config.iterative || {
355
+ maxIterations: 5,
356
+ firstPassFileLimit: 10,
357
+ subsequentPassFileLimit: 5,
358
+ temperature: 0.3,
359
+ model: 'gpt-4-turbo-preview'
360
+ };
361
+ }
362
+
334
363
  /**
335
364
  * Clear the config cache (force reload on next access)
336
365
  */
@@ -1,6 +1,7 @@
1
1
  import * as plugins from '../plugins.js';
2
2
  import * as fs from 'fs';
3
3
  import type { ICacheEntry, ICacheConfig } from './types.js';
4
+ import { logger } from '../logging.js';
4
5
 
5
6
  /**
6
7
  * ContextCache provides persistent caching of file contents and token counts
@@ -22,7 +22,9 @@ import type {
22
22
  ICacheEntry,
23
23
  IFileDependencies,
24
24
  IFileAnalysis,
25
- IAnalysisResult
25
+ IAnalysisResult,
26
+ IIterativeConfig,
27
+ IIterativeContextResult
26
28
  } from './types.js';
27
29
 
28
30
  export {
@@ -54,5 +56,7 @@ export type {
54
56
  ICacheEntry,
55
57
  IFileDependencies,
56
58
  IFileAnalysis,
57
- IAnalysisResult
59
+ IAnalysisResult,
60
+ IIterativeConfig,
61
+ IIterativeContextResult
58
62
  };