@ai-coders/context 0.1.0 → 0.2.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.
Files changed (133) hide show
  1. package/dist/generators/agents/agentConfig.d.ts +4 -0
  2. package/dist/generators/agents/agentConfig.d.ts.map +1 -0
  3. package/dist/generators/agents/agentConfig.js +138 -0
  4. package/dist/generators/agents/agentConfig.js.map +1 -0
  5. package/dist/generators/agents/agentGenerator.d.ts +13 -0
  6. package/dist/generators/agents/agentGenerator.d.ts.map +1 -0
  7. package/dist/generators/agents/agentGenerator.js +80 -0
  8. package/dist/generators/agents/agentGenerator.js.map +1 -0
  9. package/dist/generators/agents/agentTypes.d.ts +4 -0
  10. package/dist/generators/agents/agentTypes.d.ts.map +1 -0
  11. package/dist/generators/agents/agentTypes.js +22 -0
  12. package/dist/generators/agents/agentTypes.js.map +1 -0
  13. package/dist/generators/agents/contextUtils.d.ts +8 -0
  14. package/dist/generators/agents/contextUtils.d.ts.map +1 -0
  15. package/dist/generators/agents/contextUtils.js +15 -0
  16. package/dist/generators/agents/contextUtils.js.map +1 -0
  17. package/dist/generators/agents/index.d.ts +6 -0
  18. package/dist/generators/agents/index.d.ts.map +1 -0
  19. package/dist/generators/agents/index.js +16 -0
  20. package/dist/generators/agents/index.js.map +1 -0
  21. package/dist/generators/agents/promptFormatter.d.ts +9 -0
  22. package/dist/generators/agents/promptFormatter.d.ts.map +1 -0
  23. package/dist/generators/agents/promptFormatter.js +84 -0
  24. package/dist/generators/agents/promptFormatter.js.map +1 -0
  25. package/dist/generators/analyzers/codebaseAnalyzer.d.ts +45 -0
  26. package/dist/generators/analyzers/codebaseAnalyzer.d.ts.map +1 -0
  27. package/dist/generators/analyzers/codebaseAnalyzer.js +293 -0
  28. package/dist/generators/analyzers/codebaseAnalyzer.js.map +1 -0
  29. package/dist/generators/analyzers/index.d.ts +3 -0
  30. package/dist/generators/analyzers/index.d.ts.map +1 -0
  31. package/dist/generators/analyzers/index.js +6 -0
  32. package/dist/generators/analyzers/index.js.map +1 -0
  33. package/dist/generators/documentation/documentationGenerator.d.ts +19 -0
  34. package/dist/generators/documentation/documentationGenerator.d.ts.map +1 -0
  35. package/dist/generators/documentation/documentationGenerator.js +127 -0
  36. package/dist/generators/documentation/documentationGenerator.js.map +1 -0
  37. package/dist/generators/documentation/documentationTemplates.d.ts +21 -0
  38. package/dist/generators/documentation/documentationTemplates.d.ts.map +1 -0
  39. package/dist/generators/documentation/documentationTemplates.js +359 -0
  40. package/dist/generators/documentation/documentationTemplates.js.map +1 -0
  41. package/dist/generators/documentation/documentationTypes.d.ts +11 -0
  42. package/dist/generators/documentation/documentationTypes.d.ts.map +1 -0
  43. package/dist/generators/documentation/documentationTypes.js +22 -0
  44. package/dist/generators/documentation/documentationTypes.js.map +1 -0
  45. package/dist/generators/documentation/documentationUtils.d.ts +7 -0
  46. package/dist/generators/documentation/documentationUtils.d.ts.map +1 -0
  47. package/dist/generators/documentation/documentationUtils.js +28 -0
  48. package/dist/generators/documentation/documentationUtils.js.map +1 -0
  49. package/dist/generators/documentation/enhancedDocumentationGenerator.d.ts +21 -0
  50. package/dist/generators/documentation/enhancedDocumentationGenerator.d.ts.map +1 -0
  51. package/dist/generators/documentation/enhancedDocumentationGenerator.js +216 -0
  52. package/dist/generators/documentation/enhancedDocumentationGenerator.js.map +1 -0
  53. package/dist/generators/documentation/incrementalDocumentationGenerator.d.ts +33 -0
  54. package/dist/generators/documentation/incrementalDocumentationGenerator.d.ts.map +1 -0
  55. package/dist/generators/documentation/incrementalDocumentationGenerator.js +400 -0
  56. package/dist/generators/documentation/incrementalDocumentationGenerator.js.map +1 -0
  57. package/dist/generators/documentation/index.d.ts +8 -0
  58. package/dist/generators/documentation/index.d.ts.map +1 -0
  59. package/dist/generators/documentation/index.js +22 -0
  60. package/dist/generators/documentation/index.js.map +1 -0
  61. package/dist/generators/documentation/newDocumentationTemplates.d.ts +19 -0
  62. package/dist/generators/documentation/newDocumentationTemplates.d.ts.map +1 -0
  63. package/dist/generators/documentation/newDocumentationTemplates.js +307 -0
  64. package/dist/generators/documentation/newDocumentationTemplates.js.map +1 -0
  65. package/dist/generators/documentationGenerator.d.ts +3 -21
  66. package/dist/generators/documentationGenerator.d.ts.map +1 -1
  67. package/dist/generators/documentationGenerator.js +46 -597
  68. package/dist/generators/documentationGenerator.js.map +1 -1
  69. package/dist/generators/documentationTemplates.d.ts +16 -0
  70. package/dist/generators/documentationTemplates.d.ts.map +1 -0
  71. package/dist/generators/documentationTemplates.js +326 -0
  72. package/dist/generators/documentationTemplates.js.map +1 -0
  73. package/dist/generators/documentationUtils.d.ts +7 -0
  74. package/dist/generators/documentationUtils.d.ts.map +1 -0
  75. package/dist/generators/documentationUtils.js +38 -0
  76. package/dist/generators/documentationUtils.js.map +1 -0
  77. package/dist/generators/guidelines/agentIntegration.d.ts +43 -0
  78. package/dist/generators/guidelines/agentIntegration.d.ts.map +1 -0
  79. package/dist/generators/guidelines/agentIntegration.js +157 -0
  80. package/dist/generators/guidelines/agentIntegration.js.map +1 -0
  81. package/dist/generators/guidelines/guidelineTypes.d.ts +40 -0
  82. package/dist/generators/guidelines/guidelineTypes.d.ts.map +1 -0
  83. package/dist/generators/guidelines/guidelineTypes.js +144 -0
  84. package/dist/generators/guidelines/guidelineTypes.js.map +1 -0
  85. package/dist/generators/guidelines/guidelinesAnalyzer.d.ts +30 -0
  86. package/dist/generators/guidelines/guidelinesAnalyzer.d.ts.map +1 -0
  87. package/dist/generators/guidelines/guidelinesAnalyzer.js +263 -0
  88. package/dist/generators/guidelines/guidelinesAnalyzer.js.map +1 -0
  89. package/dist/generators/guidelines/guidelinesGenerator.d.ts +30 -0
  90. package/dist/generators/guidelines/guidelinesGenerator.d.ts.map +1 -0
  91. package/dist/generators/guidelines/guidelinesGenerator.js +249 -0
  92. package/dist/generators/guidelines/guidelinesGenerator.js.map +1 -0
  93. package/dist/generators/guidelines/guidelinesTemplates.d.ts +23 -0
  94. package/dist/generators/guidelines/guidelinesTemplates.d.ts.map +1 -0
  95. package/dist/generators/guidelines/guidelinesTemplates.js +304 -0
  96. package/dist/generators/guidelines/guidelinesTemplates.js.map +1 -0
  97. package/dist/generators/guidelines/index.d.ts +6 -0
  98. package/dist/generators/guidelines/index.d.ts.map +1 -0
  99. package/dist/generators/guidelines/index.js +16 -0
  100. package/dist/generators/guidelines/index.js.map +1 -0
  101. package/dist/generators/moduleGrouper.d.ts +14 -0
  102. package/dist/generators/moduleGrouper.d.ts.map +1 -0
  103. package/dist/generators/moduleGrouper.js +82 -0
  104. package/dist/generators/moduleGrouper.js.map +1 -0
  105. package/dist/generators/projectAnalyzer.d.ts +14 -0
  106. package/dist/generators/projectAnalyzer.d.ts.map +1 -0
  107. package/dist/generators/projectAnalyzer.js +217 -0
  108. package/dist/generators/projectAnalyzer.js.map +1 -0
  109. package/dist/generators/shared/contextGenerator.d.ts +12 -0
  110. package/dist/generators/shared/contextGenerator.d.ts.map +1 -0
  111. package/dist/generators/shared/contextGenerator.js +109 -0
  112. package/dist/generators/shared/contextGenerator.js.map +1 -0
  113. package/dist/generators/shared/generatorUtils.d.ts +16 -0
  114. package/dist/generators/shared/generatorUtils.d.ts.map +1 -0
  115. package/dist/generators/shared/generatorUtils.js +119 -0
  116. package/dist/generators/shared/generatorUtils.js.map +1 -0
  117. package/dist/generators/shared/index.d.ts +3 -0
  118. package/dist/generators/shared/index.d.ts.map +1 -0
  119. package/dist/generators/shared/index.js +8 -0
  120. package/dist/generators/shared/index.js.map +1 -0
  121. package/dist/index.d.ts +1 -0
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +230 -13
  124. package/dist/index.js.map +1 -1
  125. package/dist/utils/interactiveMode.d.ts +6 -1
  126. package/dist/utils/interactiveMode.d.ts.map +1 -1
  127. package/dist/utils/interactiveMode.js +375 -70
  128. package/dist/utils/interactiveMode.js.map +1 -1
  129. package/dist/utils/tokenEstimator.d.ts +10 -9
  130. package/dist/utils/tokenEstimator.d.ts.map +1 -1
  131. package/dist/utils/tokenEstimator.js +45 -109
  132. package/dist/utils/tokenEstimator.js.map +1 -1
  133. package/package.json +1 -1
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.EnhancedDocumentationGenerator = void 0;
37
+ const path = __importStar(require("path"));
38
+ const moduleGrouper_1 = require("../moduleGrouper");
39
+ const shared_1 = require("../shared");
40
+ const newDocumentationTemplates_1 = require("./newDocumentationTemplates");
41
+ const documentationTemplates_1 = require("./documentationTemplates");
42
+ const documentationTypes_1 = require("./documentationTypes");
43
+ class EnhancedDocumentationGenerator {
44
+ constructor(fileMapper, llmClient) {
45
+ this.fileMapper = fileMapper;
46
+ this.llmClient = llmClient;
47
+ this.moduleGrouper = new moduleGrouper_1.ModuleGrouper(fileMapper);
48
+ this.newTemplates = new newDocumentationTemplates_1.NewDocumentationTemplates(llmClient, fileMapper);
49
+ this.legacyTemplates = new documentationTemplates_1.DocumentationTemplates(llmClient);
50
+ }
51
+ async generateDocumentation(repoStructure, outputDir, config = {}, verbose = false) {
52
+ const fullConfig = {
53
+ enableLegacyDocs: false,
54
+ enableNewDocs: true,
55
+ focusAreas: [],
56
+ maxContentLength: 2000,
57
+ includeExamples: true,
58
+ ...config
59
+ };
60
+ const docsDir = path.join(outputDir, 'docs');
61
+ await shared_1.GeneratorUtils.ensureDirectoryAndLog(docsDir, verbose, 'šŸ“š Generating enhanced documentation in');
62
+ const moduleGroups = this.moduleGrouper.getModuleGroups(repoStructure);
63
+ if (fullConfig.enableNewDocs) {
64
+ await this.generateNewStyleDocumentation(repoStructure, moduleGroups, docsDir, verbose);
65
+ }
66
+ if (fullConfig.enableLegacyDocs) {
67
+ await this.generateLegacyDocumentation(repoStructure, moduleGroups, docsDir, verbose);
68
+ }
69
+ // Generate combined index
70
+ await this.generateMainIndex(docsDir, fullConfig, verbose);
71
+ }
72
+ async generateNewStyleDocumentation(repoStructure, moduleGroups, docsDir, verbose) {
73
+ shared_1.GeneratorUtils.logProgress('🧠 Generating high-level conceptual documentation...', verbose);
74
+ const generators = {
75
+ 'mental-model': () => this.newTemplates.createMentalModel(repoStructure, moduleGroups),
76
+ 'architecture-decisions': () => this.newTemplates.createArchitectureDecisions(repoStructure, moduleGroups),
77
+ 'code-organization': () => this.newTemplates.createCodeOrganization(repoStructure, moduleGroups),
78
+ 'development-patterns': () => this.newTemplates.createDevelopmentPatterns(repoStructure, moduleGroups),
79
+ 'ai-guidelines': () => this.newTemplates.createAIGuidelines(repoStructure, moduleGroups),
80
+ 'contributing-workflows': () => this.newTemplates.createContributingWorkflows(repoStructure, moduleGroups),
81
+ 'domain-context': () => this.newTemplates.createDomainContext(repoStructure, moduleGroups)
82
+ };
83
+ for (const docType of documentationTypes_1.NEW_DOCUMENTATION_TYPES) {
84
+ try {
85
+ const content = await generators[docType]();
86
+ const fileName = `${docType}.md`;
87
+ const filePath = path.join(docsDir, fileName);
88
+ await shared_1.GeneratorUtils.writeFileWithLogging(filePath, content, verbose, `Generated ${shared_1.GeneratorUtils.formatTitle(docType)}`);
89
+ }
90
+ catch (error) {
91
+ shared_1.GeneratorUtils.logError(`Error generating ${docType}`, error, verbose);
92
+ }
93
+ }
94
+ }
95
+ async generateLegacyDocumentation(repoStructure, moduleGroups, docsDir, verbose) {
96
+ shared_1.GeneratorUtils.logProgress('šŸ“ Generating legacy detailed documentation...', verbose);
97
+ // Create legacy subdirectory
98
+ const legacyDir = path.join(docsDir, 'legacy');
99
+ await shared_1.GeneratorUtils.ensureDirectoryAndLog(legacyDir, verbose, 'Creating legacy docs directory');
100
+ // Generate legacy documentation types
101
+ const legacyGenerators = [
102
+ { name: 'overview.md', generator: () => this.legacyTemplates.createEnhancedProjectOverview(repoStructure) },
103
+ { name: 'architecture.md', generator: () => this.legacyTemplates.createArchitectureDocumentation(repoStructure, moduleGroups) },
104
+ { name: 'api-reference.md', generator: () => this.legacyTemplates.createAPIReference(repoStructure, moduleGroups) },
105
+ { name: 'configuration.md', generator: () => this.legacyTemplates.createConfigurationGuide(repoStructure) },
106
+ { name: 'development.md', generator: () => this.legacyTemplates.createDevelopmentGuide(repoStructure, moduleGroups) },
107
+ { name: 'deployment.md', generator: () => this.legacyTemplates.createDeploymentGuide(repoStructure) },
108
+ { name: 'troubleshooting.md', generator: () => this.legacyTemplates.createTroubleshootingGuide(repoStructure, moduleGroups) }
109
+ ];
110
+ for (const { name, generator } of legacyGenerators) {
111
+ try {
112
+ const content = await generator();
113
+ const filePath = path.join(legacyDir, name);
114
+ await shared_1.GeneratorUtils.writeFileWithLogging(filePath, content, verbose, `Generated legacy ${name}`);
115
+ }
116
+ catch (error) {
117
+ shared_1.GeneratorUtils.logError(`Error generating legacy ${name}`, error, verbose);
118
+ }
119
+ }
120
+ }
121
+ async generateMainIndex(docsDir, config, verbose) {
122
+ let indexContent;
123
+ if (config.enableNewDocs && config.enableLegacyDocs) {
124
+ // Both enabled - create combined index
125
+ indexContent = this.createCombinedIndex();
126
+ }
127
+ else if (config.enableNewDocs) {
128
+ // Only new docs
129
+ indexContent = this.newTemplates.createNewDocumentationIndex(documentationTypes_1.NEW_DOCUMENTATION_TYPES);
130
+ }
131
+ else {
132
+ // Only legacy docs
133
+ indexContent = this.createLegacyOnlyIndex();
134
+ }
135
+ const indexPath = path.join(docsDir, 'README.md');
136
+ await shared_1.GeneratorUtils.writeFileWithLogging(indexPath, indexContent, verbose, 'Generated documentation index');
137
+ }
138
+ createCombinedIndex() {
139
+ return `# Documentation Hub
140
+
141
+ This project provides two styles of documentation to meet different needs:
142
+
143
+ ## 🧠 High-Level Documentation (Recommended)
144
+
145
+ **Focus**: Understanding concepts, patterns, and how to work with the codebase
146
+
147
+ - [**Mental Model**](./mental-model.md) - Core concepts and metaphors
148
+ - [**Architecture Decisions**](./architecture-decisions.md) - Key design choices and rationale
149
+ - [**Code Organization**](./code-organization.md) - Structure and organization logic
150
+ - [**Development Patterns**](./development-patterns.md) - How to work effectively in this codebase
151
+ - [**AI Guidelines**](./ai-guidelines.md) - Guidance for AI agents
152
+ - [**Contributing Workflows**](./contributing-workflows.md) - Processes and procedures
153
+ - [**Domain Context**](./domain-context.md) - Business and domain knowledge
154
+
155
+ ## šŸ“ Detailed Documentation (Legacy)
156
+
157
+ **Focus**: Comprehensive technical details and implementation specifics
158
+
159
+ - [**Overview**](./legacy/overview.md) - Project statistics and structure
160
+ - [**Architecture**](./legacy/architecture.md) - Technical architecture details
161
+ - [**API Reference**](./legacy/api-reference.md) - Complete API documentation
162
+ - [**Configuration**](./legacy/configuration.md) - Setup and configuration guides
163
+ - [**Development**](./legacy/development.md) - Development environment setup
164
+ - [**Deployment**](./legacy/deployment.md) - Deployment procedures
165
+ - [**Troubleshooting**](./legacy/troubleshooting.md) - Common issues and solutions
166
+
167
+ ## Recommended Reading Order
168
+
169
+ **For New Team Members:**
170
+ 1. Mental Model → Architecture Decisions → Code Organization → Development Patterns
171
+
172
+ **For AI Agents:**
173
+ 1. Mental Model → AI Guidelines → Development Patterns → Code Organization
174
+
175
+ **For Detailed Reference:**
176
+ Legacy documentation provides comprehensive technical details when needed.
177
+
178
+ ${shared_1.GeneratorUtils.createGeneratedByFooter('Documentation Hub')}`;
179
+ }
180
+ createLegacyOnlyIndex() {
181
+ return `# Documentation Index
182
+
183
+ This documentation provides comprehensive technical details about the project.
184
+
185
+ ## Available Documentation
186
+
187
+ - [**Overview**](./legacy/overview.md) - Project statistics and structure
188
+ - [**Architecture**](./legacy/architecture.md) - Technical architecture details
189
+ - [**API Reference**](./legacy/api-reference.md) - Complete API documentation
190
+ - [**Configuration**](./legacy/configuration.md) - Setup and configuration guides
191
+ - [**Development**](./legacy/development.md) - Development environment setup
192
+ - [**Deployment**](./legacy/deployment.md) - Deployment procedures
193
+ - [**Troubleshooting**](./legacy/troubleshooting.md) - Common issues and solutions
194
+
195
+ ${shared_1.GeneratorUtils.createGeneratedByFooter('Legacy Documentation Index')}`;
196
+ }
197
+ // Convenience methods for specific documentation types
198
+ async generateMentalModelOnly(repoStructure, outputDir, verbose = false) {
199
+ const docsDir = path.join(outputDir, 'docs');
200
+ await shared_1.GeneratorUtils.ensureDirectoryAndLog(docsDir, verbose, '🧠 Generating mental model documentation');
201
+ const moduleGroups = this.moduleGrouper.getModuleGroups(repoStructure);
202
+ const content = await this.newTemplates.createMentalModel(repoStructure, moduleGroups);
203
+ const filePath = path.join(docsDir, 'mental-model.md');
204
+ await shared_1.GeneratorUtils.writeFileWithLogging(filePath, content, verbose, 'Generated Mental Model');
205
+ }
206
+ async generateAIGuidelinesOnly(repoStructure, outputDir, verbose = false) {
207
+ const docsDir = path.join(outputDir, 'docs');
208
+ await shared_1.GeneratorUtils.ensureDirectoryAndLog(docsDir, verbose, 'šŸ¤– Generating AI guidelines documentation');
209
+ const moduleGroups = this.moduleGrouper.getModuleGroups(repoStructure);
210
+ const content = await this.newTemplates.createAIGuidelines(repoStructure, moduleGroups);
211
+ const filePath = path.join(docsDir, 'ai-guidelines.md');
212
+ await shared_1.GeneratorUtils.writeFileWithLogging(filePath, content, verbose, 'Generated AI Guidelines');
213
+ }
214
+ }
215
+ exports.EnhancedDocumentationGenerator = EnhancedDocumentationGenerator;
216
+ //# sourceMappingURL=enhancedDocumentationGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enhancedDocumentationGenerator.js","sourceRoot":"","sources":["../../../src/generators/documentation/enhancedDocumentationGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAI7B,oDAA8D;AAC9D,sCAA2C;AAC3C,2EAAwE;AACxE,qEAAkE;AAClE,6DAK8B;AAE9B,MAAa,8BAA8B;IAKzC,YACU,UAAsB,EACtB,SAAwB;QADxB,eAAU,GAAV,UAAU,CAAY;QACtB,cAAS,GAAT,SAAS,CAAe;QAEhC,IAAI,CAAC,aAAa,GAAG,IAAI,6BAAa,CAAC,UAAU,CAAC,CAAC;QACnD,IAAI,CAAC,YAAY,GAAG,IAAI,qDAAyB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACzE,IAAI,CAAC,eAAe,GAAG,IAAI,+CAAsB,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,qBAAqB,CACzB,aAA4B,EAC5B,SAAiB,EACjB,SAAuC,EAAE,EACzC,UAAmB,KAAK;QAExB,MAAM,UAAU,GAAwB;YACtC,gBAAgB,EAAE,KAAK;YACvB,aAAa,EAAE,IAAI;YACnB,UAAU,EAAE,EAAE;YACd,gBAAgB,EAAE,IAAI;YACtB,eAAe,EAAE,IAAI;YACrB,GAAG,MAAM;SACV,CAAC;QAEF,MAAM,OAAO,G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from '../../services/baseLLMClient';
4
+ import { GitService, GitChanges } from '../../utils/gitService';
5
+ export declare class IncrementalDocumentationGenerator {
6
+ private fileMapper;
7
+ private llmClient;
8
+ private gitService;
9
+ constructor(fileMapper: FileMapper, llmClient: BaseLLMClient, gitService: GitService);
10
+ updateDocumentation(repoStructure: RepoStructure, outputDir: string, changes: GitChanges, verbose?: boolean): Promise<{
11
+ updated: number;
12
+ removed: number;
13
+ updatedFiles: string[];
14
+ removedFiles: string[];
15
+ overviewUpdated: boolean;
16
+ }>;
17
+ private getAffectedModules;
18
+ private getModuleNameForFile;
19
+ private getModuleKey;
20
+ private getModuleGroups;
21
+ private formatModuleName;
22
+ private getModuleDescription;
23
+ private updateModuleDocumentation;
24
+ private createModuleDocumentation;
25
+ private cleanupEmptyModules;
26
+ private updateOverviewDocuments;
27
+ private displayChangeSummary;
28
+ private createEnhancedProjectOverview;
29
+ private createDocumentationIndex;
30
+ private slugify;
31
+ private formatBytes;
32
+ }
33
+ //# sourceMappingURL=incrementalDocumentationGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incrementalDocumentationGenerator.d.ts","sourceRoot":"","sources":["../../../src/generators/documentation/incrementalDocumentationGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAShE,qBAAa,iCAAiC;IAE1C,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;gBAFV,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU;IAG1B,mBAAmB,CACvB,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,OAAe,GACvB,OAAO,CAAC;QACT,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;IA+FF,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAgCvB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,oBAAoB;YAYd,yBAAyB;YAyBzB,yBAAyB;YA2DzB,mBAAmB;YA6BnB,uBAAuB;IAkCrC,OAAO,CAAC,oBAAoB;YAad,6BAA6B;IAoC3C,OAAO,CAAC,wBAAwB;IAmChC,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,WAAW;CAOpB"}
@@ -0,0 +1,400 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.IncrementalDocumentationGenerator = void 0;
40
+ const fs = __importStar(require("fs-extra"));
41
+ const path = __importStar(require("path"));
42
+ const chalk_1 = __importDefault(require("chalk"));
43
+ class IncrementalDocumentationGenerator {
44
+ constructor(fileMapper, llmClient, gitService) {
45
+ this.fileMapper = fileMapper;
46
+ this.llmClient = llmClient;
47
+ this.gitService = gitService;
48
+ }
49
+ async updateDocumentation(repoStructure, outputDir, changes, verbose = false) {
50
+ const docsDir = path.join(outputDir, 'docs');
51
+ await fs.ensureDir(docsDir);
52
+ if (verbose) {
53
+ console.log(chalk_1.default.blue(`šŸ“š Updating documentation in: ${docsDir}`));
54
+ this.displayChangeSummary(changes);
55
+ }
56
+ let updated = 0;
57
+ let removed = 0;
58
+ const updatedFiles = [];
59
+ const removedFiles = [];
60
+ let overviewUpdated = false;
61
+ // Get all changed files
62
+ const allChangedFiles = [
63
+ ...changes.added,
64
+ ...changes.modified,
65
+ ...changes.deleted,
66
+ ...changes.renamed.map(r => r.from),
67
+ ...changes.renamed.map(r => r.to)
68
+ ];
69
+ // Filter for tracked and relevant files only
70
+ const trackedChangedFiles = this.gitService.filterTrackedFiles(allChangedFiles);
71
+ const relevantChangedFiles = trackedChangedFiles.filter(file => {
72
+ const fullPath = path.join(repoStructure.rootPath, file);
73
+ return this.fileMapper.isTextFile(fullPath);
74
+ });
75
+ if (verbose) {
76
+ const untrackedFiles = allChangedFiles.filter(file => !trackedChangedFiles.includes(file));
77
+ if (untrackedFiles.length > 0) {
78
+ console.log(chalk_1.default.gray(`šŸ“Ž Skipping ${untrackedFiles.length} untracked files`));
79
+ }
80
+ }
81
+ if (relevantChangedFiles.length === 0) {
82
+ if (verbose) {
83
+ console.log(chalk_1.default.yellow('šŸ“„ No relevant tracked file changes detected'));
84
+ }
85
+ return {
86
+ updated: 0,
87
+ removed: 0,
88
+ updatedFiles: [],
89
+ removedFiles: [],
90
+ overviewUpdated: false
91
+ };
92
+ }
93
+ // Determine which modules are affected by the changes
94
+ const affectedModules = this.getAffectedModules(relevantChangedFiles, repoStructure);
95
+ if (verbose) {
96
+ console.log(chalk_1.default.yellow(`šŸ“¦ Updating ${affectedModules.length} affected modules...`));
97
+ affectedModules.forEach(module => {
98
+ console.log(chalk_1.default.gray(` - ${module.name} (${module.files.length} files)`));
99
+ });
100
+ }
101
+ // Update affected modules
102
+ for (const module of affectedModules) {
103
+ try {
104
+ const updatedFile = await this.updateModuleDocumentation(module, repoStructure, docsDir, verbose);
105
+ updatedFiles.push(updatedFile);
106
+ updated++;
107
+ }
108
+ catch (error) {
109
+ if (verbose) {
110
+ console.log(chalk_1.default.red(`āŒ Error updating module ${module.name}: ${error}`));
111
+ }
112
+ }
113
+ }
114
+ // Handle deleted files by checking if any modules became empty
115
+ const cleanedUpFiles = await this.cleanupEmptyModules(docsDir, repoStructure, verbose);
116
+ removedFiles.push(...cleanedUpFiles);
117
+ removed += cleanedUpFiles.length;
118
+ // Update overview documents if there were significant changes
119
+ if (updated > 0 || removed > 0) {
120
+ await this.updateOverviewDocuments(repoStructure, docsDir, verbose);
121
+ overviewUpdated = true;
122
+ updatedFiles.push('README.md', 'overview.md');
123
+ }
124
+ return {
125
+ updated,
126
+ removed,
127
+ updatedFiles,
128
+ removedFiles,
129
+ overviewUpdated
130
+ };
131
+ }
132
+ getAffectedModules(changedFiles, repoStructure) {
133
+ // Get all modules
134
+ const allModules = this.getModuleGroups(repoStructure);
135
+ // Find which modules contain changed files
136
+ const affectedModuleNames = new Set();
137
+ changedFiles.forEach(changedFile => {
138
+ const moduleName = this.getModuleNameForFile(changedFile);
139
+ affectedModuleNames.add(moduleName);
140
+ });
141
+ // Return only the affected modules
142
+ return allModules.filter(module => affectedModuleNames.has(this.getModuleKey(module.name)));
143
+ }
144
+ getModuleNameForFile(relativePath) {
145
+ const parts = relativePath.split(path.sep);
146
+ let groupName = 'Root Files';
147
+ if (parts.length > 1) {
148
+ groupName = parts[0];
149
+ // Special handling for src files
150
+ if (groupName === 'src' && parts.length > 2) {
151
+ groupName = parts[1];
152
+ }
153
+ }
154
+ return groupName;
155
+ }
156
+ getModuleKey(moduleName) {
157
+ return moduleName.toLowerCase().replace(/\s+/g, '-');
158
+ }
159
+ getModuleGroups(repoStructure) {
160
+ const groups = new Map();
161
+ // Group files by their top-level directory or logical module
162
+ repoStructure.files.forEach(file => {
163
+ if (!this.fileMapper.isTextFile(file.path))
164
+ return;
165
+ const parts = file.relativePath.split(path.sep);
166
+ let groupName = 'Root Files';
167
+ if (parts.length > 1) {
168
+ groupName = parts[0];
169
+ // Special handling for src files
170
+ if (groupName === 'src' && parts.length > 2) {
171
+ groupName = parts[1];
172
+ }
173
+ }
174
+ if (!groups.has(groupName)) {
175
+ groups.set(groupName, []);
176
+ }
177
+ groups.get(groupName).push(file);
178
+ });
179
+ // Convert to ModuleGroup array with descriptions
180
+ return Array.from(groups.entries()).map(([name, files]) => ({
181
+ name: this.formatModuleName(name),
182
+ description: this.getModuleDescription(name, files),
183
+ files
184
+ })).sort((a, b) => a.name.localeCompare(b.name));
185
+ }
186
+ formatModuleName(name) {
187
+ return name
188
+ .split(/[-_]/)
189
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1))
190
+ .join(' ');
191
+ }
192
+ getModuleDescription(name, files) {
193
+ const descriptions = {
194
+ 'generators': 'Code generation utilities for documentation and agents',
195
+ 'services': 'External service integrations and API clients',
196
+ 'utils': 'Utility functions and helper modules',
197
+ 'types': 'TypeScript type definitions and interfaces',
198
+ 'Root Files': 'Main configuration and entry point files'
199
+ };
200
+ return descriptions[name] || `${this.formatModuleName(name)} module with ${files.length} files`;
201
+ }
202
+ async updateModuleDocumentation(module, repoStructure, docsDir, verbose) {
203
+ const modulesDir = path.join(docsDir, 'modules');
204
+ await fs.ensureDir(modulesDir);
205
+ const fileName = `${this.slugify(module.name)}.md`;
206
+ if (verbose) {
207
+ console.log(chalk_1.default.blue(`šŸ“„ Updating modules/${fileName}...`));
208
+ }
209
+ const moduleDoc = await this.createModuleDocumentation(module, repoStructure);
210
+ const modulePath = path.join(modulesDir, fileName);
211
+ await fs.writeFile(modulePath, moduleDoc);
212
+ if (verbose) {
213
+ console.log(chalk_1.default.green(`āœ… Updated modules/${fileName}`));
214
+ }
215
+ return path.relative(docsDir, modulePath);
216
+ }
217
+ async createModuleDocumentation(module, _repoStructure) {
218
+ const fileContents = [];
219
+ for (const file of module.files.slice(0, 10)) { // Limit to prevent too large requests
220
+ try {
221
+ const content = await this.fileMapper.readFileContent(file.path);
222
+ fileContents.push(`File: ${file.relativePath}\n${content.substring(0, 1000)}...`);
223
+ }
224
+ catch (error) {
225
+ fileContents.push(`File: ${file.relativePath}\n[Error reading file: ${error}]`);
226
+ }
227
+ }
228
+ const moduleContext = `Module: ${module.name}
229
+ Description: ${module.description}
230
+ Files: ${module.files.map(f => f.relativePath).join(', ')}
231
+
232
+ Sample content from module files:
233
+ ${fileContents.join('\n\n---\n\n')}`;
234
+ const documentation = await this.llmClient.generateText(`Generate comprehensive documentation for this module. Include:
235
+ 1. Module overview and purpose
236
+ 2. Key components and their responsibilities
237
+ 3. Public APIs and interfaces
238
+ 4. Usage examples
239
+ 5. Dependencies and relationships
240
+
241
+ Module context:
242
+ ${moduleContext}`, 'You are a technical documentation expert. Create clear, well-structured module documentation.');
243
+ // Add metadata header
244
+ const history = this.gitService.getFileHistory(module.files[0]?.relativePath || '', 1);
245
+ const lastModified = history[0]?.date || new Date().toISOString();
246
+ return `---
247
+ module: ${module.name}
248
+ files: ${module.files.length}
249
+ last_modified: ${lastModified}
250
+ generated: ${new Date().toISOString()}
251
+ ---
252
+
253
+ # ${module.name}
254
+
255
+ ${documentation}
256
+
257
+ ## Files in this module
258
+
259
+ ${module.files.map(file => `- \`${file.relativePath}\` - ${this.formatBytes(file.size)}`).join('\n')}
260
+
261
+ ---
262
+ *Generated by AI Coders Context*
263
+ `;
264
+ }
265
+ async cleanupEmptyModules(docsDir, repoStructure, verbose) {
266
+ const modulesDir = path.join(docsDir, 'modules');
267
+ if (!await fs.pathExists(modulesDir))
268
+ return [];
269
+ const existingModuleFiles = await fs.readdir(modulesDir);
270
+ const currentModules = new Set(this.getModuleGroups(repoStructure).map(m => `${this.slugify(m.name)}.md`));
271
+ const removedFiles = [];
272
+ for (const moduleFile of existingModuleFiles) {
273
+ if (!currentModules.has(moduleFile)) {
274
+ const modulePath = path.join(modulesDir, moduleFile);
275
+ await fs.remove(modulePath);
276
+ removedFiles.push(path.join('modules', moduleFile));
277
+ if (verbose) {
278
+ console.log(chalk_1.default.red(`šŸ—‘ļø Removed empty module: ${moduleFile}`));
279
+ }
280
+ }
281
+ }
282
+ return removedFiles;
283
+ }
284
+ async updateOverviewDocuments(repoStructure, docsDir, verbose) {
285
+ // Update project overview
286
+ const overviewFileName = 'overview.md';
287
+ if (verbose) {
288
+ console.log(chalk_1.default.blue(`šŸ“„ Updating ${overviewFileName}...`));
289
+ }
290
+ const overview = await this.createEnhancedProjectOverview(repoStructure);
291
+ const overviewPath = path.join(docsDir, overviewFileName);
292
+ await fs.writeFile(overviewPath, overview);
293
+ if (verbose) {
294
+ console.log(chalk_1.default.green(`āœ… Updated ${overviewFileName}`));
295
+ }
296
+ // Update main README
297
+ const indexFileName = 'README.md';
298
+ if (verbose) {
299
+ console.log(chalk_1.default.blue(`šŸ“„ Updating ${indexFileName}...`));
300
+ }
301
+ const indexContent = this.createDocumentationIndex(repoStructure);
302
+ const indexPath = path.join(docsDir, indexFileName);
303
+ await fs.writeFile(indexPath, indexContent);
304
+ if (verbose) {
305
+ console.log(chalk_1.default.green(`āœ… Updated ${indexFileName}`));
306
+ }
307
+ }
308
+ displayChangeSummary(changes) {
309
+ const total = changes.added.length + changes.modified.length + changes.deleted.length + changes.renamed.length;
310
+ console.log(chalk_1.default.bold('\nšŸ“‹ Change Summary:'));
311
+ console.log(chalk_1.default.gray('─'.repeat(50)));
312
+ console.log(`${chalk_1.default.green('Added:')} ${changes.added.length} files`);
313
+ console.log(`${chalk_1.default.yellow('Modified:')} ${changes.modified.length} files`);
314
+ console.log(`${chalk_1.default.red('Deleted:')} ${changes.deleted.length} files`);
315
+ console.log(`${chalk_1.default.blue('Renamed:')} ${changes.renamed.length} files`);
316
+ console.log(`${chalk_1.default.bold('Total:')} ${total} changes`);
317
+ console.log(chalk_1.default.gray('─'.repeat(50)) + '\n');
318
+ }
319
+ async createEnhancedProjectOverview(repoStructure) {
320
+ const { files, directories, totalFiles, totalSize } = repoStructure;
321
+ const branch = this.gitService.getBranchName();
322
+ const lastCommit = this.gitService.getCurrentCommit().substring(0, 7);
323
+ const extensions = new Map();
324
+ files.forEach(file => {
325
+ const ext = file.extension || 'no-extension';
326
+ extensions.set(ext, (extensions.get(ext) || 0) + 1);
327
+ });
328
+ const topExtensions = Array.from(extensions.entries())
329
+ .sort((a, b) => b[1] - a[1])
330
+ .slice(0, 10);
331
+ return `# Project Overview
332
+
333
+ ## Git Information
334
+ - **Branch**: ${branch}
335
+ - **Last Commit**: ${lastCommit}
336
+ - **Last Updated**: ${new Date().toISOString()}
337
+
338
+ ## Project Statistics
339
+ - **Total Files**: ${totalFiles}
340
+ - **Total Directories**: ${directories.length}
341
+ - **Total Size**: ${this.formatBytes(totalSize)}
342
+
343
+ ## File Distribution
344
+ ${topExtensions.map(([ext, count]) => `- **${ext}**: ${count} files (${((count / totalFiles) * 100).toFixed(1)}%)`).join('\n')}
345
+
346
+ ---
347
+ *Generated by AI Coders Context*
348
+ *Incremental update: ${new Date().toISOString()}*
349
+ `;
350
+ }
351
+ createDocumentationIndex(_repoStructure) {
352
+ const state = this.gitService.getState();
353
+ const branch = this.gitService.getBranchName();
354
+ return `# Documentation Index
355
+
356
+ This documentation was generated automatically from the codebase.
357
+
358
+ ## Documentation Structure
359
+
360
+ ### [Overview](./overview.md)
361
+ High-level project overview, statistics, and git information.
362
+
363
+ ### [Architecture](./architecture.md)
364
+ System architecture, design patterns, and technical decisions.
365
+
366
+ ### [Modules](./modules/)
367
+ Detailed documentation organized by module and directory structure.
368
+
369
+ ### [API Reference](./api-reference.md)
370
+ Complete API documentation for all public interfaces.
371
+
372
+ ### [Configuration](./configuration.md)
373
+ Configuration options, environment variables, and setup guides.
374
+
375
+ ## Generation Info
376
+ - **Branch**: ${branch}
377
+ - **Generated**: ${new Date().toISOString()}
378
+ - **Last Processed Commit**: ${state?.lastCommit ? state.lastCommit.substring(0, 7) : 'None'}
379
+
380
+ ---
381
+ *Generated by AI Coders Context*
382
+ `;
383
+ }
384
+ slugify(text) {
385
+ return text
386
+ .toLowerCase()
387
+ .replace(/\s+/g, '-')
388
+ .replace(/[^\w-]/g, '');
389
+ }
390
+ formatBytes(bytes) {
391
+ if (bytes === 0)
392
+ return '0 Bytes';
393
+ const k = 1024;
394
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
395
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
396
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
397
+ }
398
+ }
399
+ exports.IncrementalDocumentationGenerator = IncrementalDocumentationGenerator;
400
+ //# sourceMappingURL=incrementalDocumentationGenerator.js.map