@git.zone/tsdoc 1.6.1 → 1.7.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/cli.js +10 -25
- package/dist_ts/context/config-manager.d.ts +5 -1
- package/dist_ts/context/config-manager.js +27 -1
- package/dist_ts/context/context-cache.js +2 -1
- package/dist_ts/context/index.d.ts +2 -2
- package/dist_ts/context/index.js +1 -1
- package/dist_ts/context/iterative-context-builder.d.ts +58 -0
- package/dist_ts/context/iterative-context-builder.js +361 -0
- package/dist_ts/context/task-context-factory.d.ts +8 -8
- package/dist_ts/context/task-context-factory.js +17 -41
- package/dist_ts/context/types.d.ts +69 -0
- package/package.json +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/cli.ts +21 -38
- package/ts/context/config-manager.ts +34 -5
- package/ts/context/context-cache.ts +1 -0
- package/ts/context/index.ts +6 -2
- package/ts/context/iterative-context-builder.ts +467 -0
- package/ts/context/task-context-factory.ts +40 -63
- package/ts/context/types.ts +74 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as plugins from '../plugins.js';
|
|
2
|
-
import {
|
|
2
|
+
import { IterativeContextBuilder } from './iterative-context-builder.js';
|
|
3
3
|
import { ConfigManager } from './config-manager.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { IIterativeContextResult, TaskType } from './types.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Factory class for creating task-specific context
|
|
7
|
+
* Factory class for creating task-specific context using iterative context building
|
|
8
8
|
*/
|
|
9
9
|
export class TaskContextFactory {
|
|
10
10
|
private projectDir: string;
|
|
11
11
|
private configManager: ConfigManager;
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
/**
|
|
14
14
|
* Create a new TaskContextFactory
|
|
15
15
|
* @param projectDirArg The project directory
|
|
@@ -18,82 +18,61 @@ export class TaskContextFactory {
|
|
|
18
18
|
this.projectDir = projectDirArg;
|
|
19
19
|
this.configManager = ConfigManager.getInstance();
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
/**
|
|
23
23
|
* Initialize the factory
|
|
24
24
|
*/
|
|
25
25
|
public async initialize(): Promise<void> {
|
|
26
26
|
await this.configManager.initialize(this.projectDir);
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
/**
|
|
30
30
|
* Create context for README generation
|
|
31
31
|
*/
|
|
32
|
-
public async createContextForReadme(): Promise<
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
contextBuilder.setContextMode(taskConfig.mode);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Build the context for README task
|
|
43
|
-
return await contextBuilder.buildContext('readme');
|
|
32
|
+
public async createContextForReadme(): Promise<IIterativeContextResult> {
|
|
33
|
+
const iterativeBuilder = new IterativeContextBuilder(
|
|
34
|
+
this.projectDir,
|
|
35
|
+
this.configManager.getIterativeConfig()
|
|
36
|
+
);
|
|
37
|
+
await iterativeBuilder.initialize();
|
|
38
|
+
return await iterativeBuilder.buildContextIteratively('readme');
|
|
44
39
|
}
|
|
45
|
-
|
|
40
|
+
|
|
46
41
|
/**
|
|
47
42
|
* Create context for description generation
|
|
48
43
|
*/
|
|
49
|
-
public async createContextForDescription(): Promise<
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
contextBuilder.setContextMode(taskConfig.mode);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Build the context for description task
|
|
60
|
-
return await contextBuilder.buildContext('description');
|
|
44
|
+
public async createContextForDescription(): Promise<IIterativeContextResult> {
|
|
45
|
+
const iterativeBuilder = new IterativeContextBuilder(
|
|
46
|
+
this.projectDir,
|
|
47
|
+
this.configManager.getIterativeConfig()
|
|
48
|
+
);
|
|
49
|
+
await iterativeBuilder.initialize();
|
|
50
|
+
return await iterativeBuilder.buildContextIteratively('description');
|
|
61
51
|
}
|
|
62
|
-
|
|
52
|
+
|
|
63
53
|
/**
|
|
64
54
|
* Create context for commit message generation
|
|
65
|
-
* @param gitDiff Optional git diff to include
|
|
55
|
+
* @param gitDiff Optional git diff to include (currently not used in iterative mode)
|
|
66
56
|
*/
|
|
67
|
-
public async createContextForCommit(gitDiff?: string): Promise<
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Build the context for commit task
|
|
78
|
-
const contextResult = await contextBuilder.buildContext('commit');
|
|
79
|
-
|
|
80
|
-
// If git diff is provided, add it to the context
|
|
81
|
-
if (gitDiff) {
|
|
82
|
-
contextBuilder.updateWithGitDiff(gitDiff);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return contextBuilder.getContextResult();
|
|
57
|
+
public async createContextForCommit(gitDiff?: string): Promise<IIterativeContextResult> {
|
|
58
|
+
const iterativeBuilder = new IterativeContextBuilder(
|
|
59
|
+
this.projectDir,
|
|
60
|
+
this.configManager.getIterativeConfig()
|
|
61
|
+
);
|
|
62
|
+
await iterativeBuilder.initialize();
|
|
63
|
+
// Note: git diff could be incorporated into the iterative prompts if needed
|
|
64
|
+
return await iterativeBuilder.buildContextIteratively('commit');
|
|
86
65
|
}
|
|
87
|
-
|
|
66
|
+
|
|
88
67
|
/**
|
|
89
68
|
* Create context for any task type
|
|
90
69
|
* @param taskType The task type to create context for
|
|
91
|
-
* @param additionalContent Optional additional content
|
|
70
|
+
* @param additionalContent Optional additional content (currently not used)
|
|
92
71
|
*/
|
|
93
72
|
public async createContextForTask(
|
|
94
73
|
taskType: TaskType,
|
|
95
74
|
additionalContent?: string
|
|
96
|
-
): Promise<
|
|
75
|
+
): Promise<IIterativeContextResult> {
|
|
97
76
|
switch (taskType) {
|
|
98
77
|
case 'readme':
|
|
99
78
|
return this.createContextForReadme();
|
|
@@ -102,13 +81,11 @@ export class TaskContextFactory {
|
|
|
102
81
|
case 'commit':
|
|
103
82
|
return this.createContextForCommit(additionalContent);
|
|
104
83
|
default:
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
await contextBuilder.initialize();
|
|
108
|
-
return await contextBuilder.buildContext();
|
|
84
|
+
// Default to readme for unknown task types
|
|
85
|
+
return this.createContextForReadme();
|
|
109
86
|
}
|
|
110
87
|
}
|
|
111
|
-
|
|
88
|
+
|
|
112
89
|
/**
|
|
113
90
|
* Get token stats for all task types
|
|
114
91
|
*/
|
|
@@ -121,7 +98,7 @@ export class TaskContextFactory {
|
|
|
121
98
|
}>> {
|
|
122
99
|
const taskTypes: TaskType[] = ['readme', 'description', 'commit'];
|
|
123
100
|
const stats: Record<TaskType, any> = {} as any;
|
|
124
|
-
|
|
101
|
+
|
|
125
102
|
for (const taskType of taskTypes) {
|
|
126
103
|
const result = await this.createContextForTask(taskType);
|
|
127
104
|
stats[taskType] = {
|
|
@@ -132,7 +109,7 @@ export class TaskContextFactory {
|
|
|
132
109
|
excludedFiles: result.excludedFiles.length
|
|
133
110
|
};
|
|
134
111
|
}
|
|
135
|
-
|
|
112
|
+
|
|
136
113
|
return stats;
|
|
137
114
|
}
|
|
138
|
-
}
|
|
115
|
+
}
|
package/ts/context/types.ts
CHANGED
|
@@ -66,6 +66,8 @@ export interface IContextConfig {
|
|
|
66
66
|
prioritization?: IPrioritizationWeights;
|
|
67
67
|
/** Tier configuration for adaptive trimming */
|
|
68
68
|
tiers?: ITierConfig;
|
|
69
|
+
/** Iterative context building configuration */
|
|
70
|
+
iterative?: IIterativeConfig;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
/**
|
|
@@ -244,4 +246,76 @@ export interface IAnalysisResult {
|
|
|
244
246
|
totalFiles: number;
|
|
245
247
|
/** Analysis duration in ms */
|
|
246
248
|
analysisDuration: number;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Configuration for iterative context building
|
|
253
|
+
*/
|
|
254
|
+
export interface IIterativeConfig {
|
|
255
|
+
/** Maximum number of iterations allowed */
|
|
256
|
+
maxIterations?: number;
|
|
257
|
+
/** Maximum files to request in first iteration */
|
|
258
|
+
firstPassFileLimit?: number;
|
|
259
|
+
/** Maximum files to request in subsequent iterations */
|
|
260
|
+
subsequentPassFileLimit?: number;
|
|
261
|
+
/** Temperature for AI decision making (0-1) */
|
|
262
|
+
temperature?: number;
|
|
263
|
+
/** Model to use for iterative decisions */
|
|
264
|
+
model?: string;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* AI decision for file selection
|
|
269
|
+
*/
|
|
270
|
+
export interface IFileSelectionDecision {
|
|
271
|
+
/** AI's reasoning for file selection */
|
|
272
|
+
reasoning: string;
|
|
273
|
+
/** File paths to load */
|
|
274
|
+
filesToLoad: string[];
|
|
275
|
+
/** Estimated tokens needed */
|
|
276
|
+
estimatedTokensNeeded?: number;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* AI decision for context sufficiency
|
|
281
|
+
*/
|
|
282
|
+
export interface IContextSufficiencyDecision {
|
|
283
|
+
/** Whether context is sufficient */
|
|
284
|
+
sufficient: boolean;
|
|
285
|
+
/** AI's reasoning */
|
|
286
|
+
reasoning: string;
|
|
287
|
+
/** Additional files needed (if not sufficient) */
|
|
288
|
+
additionalFilesNeeded?: string[];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* State for a single iteration
|
|
293
|
+
*/
|
|
294
|
+
export interface IIterationState {
|
|
295
|
+
/** Iteration number (1-based) */
|
|
296
|
+
iteration: number;
|
|
297
|
+
/** Files loaded in this iteration */
|
|
298
|
+
filesLoaded: IFileInfo[];
|
|
299
|
+
/** Tokens used in this iteration */
|
|
300
|
+
tokensUsed: number;
|
|
301
|
+
/** Total tokens used so far */
|
|
302
|
+
totalTokensUsed: number;
|
|
303
|
+
/** AI decision made in this iteration */
|
|
304
|
+
decision: IFileSelectionDecision | IContextSufficiencyDecision;
|
|
305
|
+
/** Duration of this iteration in ms */
|
|
306
|
+
duration: number;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Result of iterative context building
|
|
311
|
+
*/
|
|
312
|
+
export interface IIterativeContextResult extends IContextResult {
|
|
313
|
+
/** Number of iterations performed */
|
|
314
|
+
iterationCount: number;
|
|
315
|
+
/** Details of each iteration */
|
|
316
|
+
iterations: IIterationState[];
|
|
317
|
+
/** Total API calls made */
|
|
318
|
+
apiCallCount: number;
|
|
319
|
+
/** Total duration in ms */
|
|
320
|
+
totalDuration: number;
|
|
247
321
|
}
|