@chappibunny/repolens 0.7.0 → 0.9.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/CHANGELOG.md CHANGED
@@ -2,6 +2,42 @@
2
2
 
3
3
  All notable changes to RepoLens will be documented in this file.
4
4
 
5
+ ## 0.9.0
6
+
7
+ ### ✨ New Features
8
+ - **Plugin System** (`src/plugins/`): Extensible architecture for custom renderers and publishers
9
+ - `loader.js`: Resolves and imports plugins from local paths or npm packages
10
+ - `manager.js`: `PluginManager` class — registry, getters, and lifecycle hook runner
11
+ - Plugin interface: `register()` → `{ name, version, renderers, publishers, hooks }`
12
+ - **Custom Renderers**: Plugins can register new document types with `render(context)` functions
13
+ - **Custom Publishers**: Plugins can register new output targets with `publish(cfg, renderedPages)` functions
14
+ - **Lifecycle Hooks**: `afterScan`, `afterRender`, `afterPublish` — transform data or trigger side effects
15
+ - Hooks run in plugin load order; errors are caught per-plugin without breaking the pipeline
16
+ - Config: `plugins: ["./my-plugin.js", "@org/repolens-plugin-foo"]` in `.repolens.yml`
17
+ - Config schema updated: `plugins` array validated, custom publisher names accepted
18
+
19
+ ### 🧪 Tests
20
+ - Added 21 new plugin tests + 21 publisher parser tests (163 tests across 14 files)
21
+
22
+ ### 🔧 Output Quality
23
+ - **Notion Publisher**: Full table support (table blocks with `table_row` children), blockquote → callout, dividers, numbered lists, h3 headings, inline rich text (`**bold**`, `*italic*`, `` `code` ``)
24
+ - **Confluence Publisher**: Rewritten as line-by-line parser — proper `<table>` HTML output, blockquotes → info panels, merged `<ul>`/`<ol>` lists, fixed code block HTML entity escaping bug
25
+ - **Renderers**: Tables replace bullet-point lists across all 8 renderers, descriptive prose, removed ASCII banner art
26
+ - **Fallback Generators**: All 6 deterministic fallbacks rewritten with tables, descriptive paragraphs, and module descriptions
27
+
28
+ ## 0.8.0
29
+
30
+ ### ✨ New Features
31
+ - **GraphQL Schema Detection** (`src/analyzers/graphql-analyzer.js`): Detects `.graphql`/`.gql` schema files, inline SDL via gql tagged templates, 11 library patterns (Apollo, Yoga, Mercurius, Nexus, Pothos, type-graphql, Relay, urql, etc.), and resolver patterns. Parses queries, mutations, subscriptions, object types, enums, inputs, interfaces, unions, scalars, and directives.
32
+ - **TypeScript Type Graph Analysis** (`src/analyzers/typescript-analyzer.js`): Parses interfaces (with extends), type aliases (with reference extraction), classes (extends + implements), enums, and generic constraints. Builds relationship graph with deduplication, filtering to project-declared types only.
33
+ - **Dependency Graph with Cycle Detection** (`src/analyzers/dependency-graph.js`): Parses ES imports, dynamic imports, CommonJS require, and re-exports. Builds directed adjacency graph with cycle detection via iterative DFS (3-color marking). Tracks hub modules, orphan files, and external dependencies.
34
+ - **Architecture Drift Detection** (`src/analyzers/drift-detector.js`): Compares current architecture against stored baseline snapshots. Detects changes across 8 categories (modules, APIs, pages, dependencies, frameworks, circular deps, GraphQL types, file count). Categorizes drifts by severity: 🔴 critical, 🟡 warning, 🟢 info. Baselines auto-saved to `.repolens/architecture-baseline.json`.
35
+ - **Extended Analysis Renderers** (`src/renderers/renderAnalysis.js`): Markdown renderers for all 4 new document types with tables, Unicode relationship trees, and severity-grouped reports.
36
+ - **4 New Document Types**: `graphql_schema`, `type_graph`, `dependency_graph`, `architecture_drift` — bringing total to 15 audience-aware documents.
37
+
38
+ ### 🧪 Tests
39
+ - Added 31 new tests for extended analysis features (121 tests across 12 files)
40
+
5
41
  ## 0.7.0
6
42
 
7
43
  ### ✨ New Features
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  Repository Intelligence CLI
9
9
  ```
10
10
 
11
- [![Tests](https://img.shields.io/badge/tests-90%20passing-brightgreen)](https://github.com/CHAPIBUNNY/repolens/actions)
11
+ [![Tests](https://img.shields.io/badge/tests-163%20passing-brightgreen)](https://github.com/CHAPIBUNNY/repolens/actions)
12
12
  [![Security](https://img.shields.io/badge/security-hardened-blue)](SECURITY.md)
13
13
  [![Vulnerabilities](https://img.shields.io/badge/vulnerabilities-0-brightgreen)](SECURITY.md)
14
14
  [![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
@@ -16,7 +16,7 @@
16
16
 
17
17
  AI-assisted documentation intelligence system that generates architecture docs for engineers AND readable system docs for stakeholders
18
18
 
19
- **Current Status**: v0.7.0 — Polish & Reliability
19
+ **Current Status**: v0.9.0 — Plugin System
20
20
 
21
21
  RepoLens automatically generates and maintains living architecture documentation by analyzing your repository structure, extracting meaningful insights from your package.json, and creating visual dependency graphs. Run it once, or let it auto-update on every push.
22
22
 
@@ -133,6 +133,10 @@ RepoLens automatically detects:
133
133
  ✅ **Interactive Setup** - Step-by-step configuration wizard (NEW in v0.7.0)
134
134
  ✅ **Performance Metrics** - Timing breakdown for scan/render/publish (NEW in v0.7.0)
135
135
  ✅ **Actionable Errors** - Enhanced error messages with fix guidance (NEW in v0.7.0)
136
+ ✅ **GraphQL Schema Detection** - Discover types, queries, mutations, and resolvers (NEW in v0.8.0)
137
+ ✅ **TypeScript Type Graph** - Map interfaces, classes, and type relationships (NEW in v0.8.0)
138
+ ✅ **Dependency Graph** - Import analysis with circular dependency detection (NEW in v0.8.0)
139
+ ✅ **Architecture Drift** - Track structural changes against a baseline (NEW in v0.8.0)
136
140
 
137
141
  ---
138
142
 
@@ -224,7 +228,7 @@ npm link
224
228
  Install from a specific version:
225
229
 
226
230
  ```bash
227
- npm install https://github.com/CHAPIBUNNY/repolens/releases/download/v0.7.0/chappibunny-repolens-0.7.0.tgz
231
+ npm install https://github.com/CHAPIBUNNY/repolens/releases/download/v0.9.0/chappibunny-repolens-0.9.0.tgz
228
232
  ```
229
233
  </details>
230
234
 
@@ -1066,7 +1070,7 @@ npm test
1066
1070
  - Integration workflows
1067
1071
  - Doctor command validation
1068
1072
 
1069
- **Coverage:** 90 tests passing across 11 test files
1073
+ **Coverage:** 163 tests passing across 14 test files
1070
1074
 
1071
1075
  ### Test Package Installation Locally
1072
1076
 
@@ -1077,7 +1081,7 @@ Simulates the full user installation experience:
1077
1081
  npm pack
1078
1082
 
1079
1083
  # Install globally from tarball
1080
- npm install -g chappibunny-repolens-0.7.0.tgz
1084
+ npm install -g chappibunny-repolens-0.9.0.tgz
1081
1085
 
1082
1086
  # Verify
1083
1087
  repolens --version
@@ -1101,9 +1105,13 @@ repolens/
1101
1105
  │ │ ├── diff.js # Git diff operations
1102
1106
  │ │ └── scan.js # Repository scanning + metadata extraction
1103
1107
  │ ├── analyzers/
1104
- │ │ ├── domain-inference.js # Business domain mapping
1105
- │ │ ├── context-builder.js # Structured AI context assembly
1106
- │ │ └── flow-inference.js # Data flow detection
1108
+ │ │ ├── domain-inference.js # Business domain mapping
1109
+ │ │ ├── context-builder.js # Structured AI context assembly
1110
+ │ │ ├── flow-inference.js # Data flow detection
1111
+ │ │ ├── graphql-analyzer.js # GraphQL schema detection
1112
+ │ │ ├── typescript-analyzer.js # TypeScript type graph analysis
1113
+ │ │ ├── dependency-graph.js # Import graph with cycle detection
1114
+ │ │ └── drift-detector.js # Architecture drift detection
1107
1115
  │ ├── ai/
1108
1116
  │ │ ├── provider.js # Provider-agnostic AI generation
1109
1117
  │ │ ├── prompts.js # Strict prompt templates
@@ -1113,9 +1121,10 @@ repolens/
1113
1121
  │ │ ├── generate-doc-set.js # Document generation orchestration
1114
1122
  │ │ └── write-doc-set.js # Write docs to disk
1115
1123
  │ ├── renderers/
1116
- │ │ ├── render.js # System overview, catalog, API, routes
1117
- │ │ ├── renderDiff.js # Architecture diff rendering
1118
- │ │ └── renderMap.js # Unicode dependency diagrams
1124
+ │ │ ├── render.js # System overview, catalog, API, routes
1125
+ │ │ ├── renderDiff.js # Architecture diff rendering
1126
+ │ │ ├── renderMap.js # Unicode dependency diagrams
1127
+ │ │ └── renderAnalysis.js # Extended analysis renderers
1119
1128
  │ ├── publishers/
1120
1129
  │ │ ├── index.js # Publisher orchestration + branch filtering
1121
1130
  │ │ ├── publish.js # Publishing pipeline
@@ -1137,7 +1146,7 @@ repolens/
1137
1146
  │ ├── telemetry.js # Opt-in error tracking + performance timers
1138
1147
  │ ├── errors.js # Enhanced error messages with guidance
1139
1148
  │ └── update-check.js # Version update notifications
1140
- ├── tests/ # Vitest test suite (90 tests across 11 files)
1149
+ ├── tests/ # Vitest test suite (163 tests across 14 files)
1141
1150
  ├── .repolens.yml # Dogfooding config
1142
1151
  ├── package.json
1143
1152
  ├── CHANGELOG.md
@@ -1154,13 +1163,13 @@ RepoLens uses automated GitHub Actions releases.
1154
1163
  ### Creating a Release
1155
1164
 
1156
1165
  ```bash
1157
- # Patch version (0.7.0 → 0.7.1) - Bug fixes
1166
+ # Patch version (0.9.0 → 0.9.1) - Bug fixes
1158
1167
  npm run release:patch
1159
1168
 
1160
- # Minor version (0.7.0 → 0.8.0) - New features
1169
+ # Minor version (0.9.0 → 0.10.0) - New features
1161
1170
  npm run release:minor
1162
1171
 
1163
- # Major version (0.7.0 → 1.0.0) - Breaking changes
1172
+ # Major version (0.9.0 → 1.0.0) - Breaking changes
1164
1173
  npm run release:major
1165
1174
 
1166
1175
  # Push the tag to trigger workflow
@@ -1192,7 +1201,7 @@ RepoLens is currently in early access. v1.0 will open for community contribution
1192
1201
 
1193
1202
  ## 🗺️ Roadmap to v1.0
1194
1203
 
1195
- **Current Status:** v0.7.0 — Polish & Reliability
1204
+ **Current Status:** v0.9.0 — Plugin System
1196
1205
 
1197
1206
  ### Completed ✅
1198
1207
 
@@ -1208,7 +1217,7 @@ RepoLens is currently in early access. v1.0 will open for community contribution
1208
1217
  - [x] GitHub Actions automation (publish + release)
1209
1218
  - [x] PR architecture diff comments
1210
1219
  - [x] Performance guardrails (10k warning, 50k limit)
1211
- - [x] Comprehensive test suite (90 tests across 11 files)
1220
+ - [x] Comprehensive test suite (163 tests across 14 files)
1212
1221
  - [x] Security hardening (secret detection, injection prevention, fuzzing)
1213
1222
  - [x] Discord notifications with rich embeds
1214
1223
  - [x] Documentation coverage & health scoring
@@ -1221,12 +1230,15 @@ RepoLens is currently in early access. v1.0 will open for community contribution
1221
1230
  - [x] Enhanced error messages with actionable guidance
1222
1231
  - [x] Performance monitoring (scan/render/publish timing)
1223
1232
  - [x] Improved documentation coverage scoring
1233
+ - [x] GraphQL schema detection (queries, mutations, types, resolvers)
1234
+ - [x] TypeScript type graph analysis (interfaces, classes, relationships)
1235
+ - [x] Dependency graph with circular dependency detection
1236
+ - [x] Architecture drift detection (baseline comparison)
1237
+ - [x] Plugin system for custom renderers and publishers
1224
1238
 
1225
1239
  ### Planned for v1.0 🎯
1226
1240
 
1227
- - [ ] Plugin system for custom renderers
1228
- - [ ] GraphQL schema detection
1229
- - [ ] TypeScript type graph analysis
1241
+ - [ ] Stability audit: freeze CLI flags and config schema
1230
1242
  - [ ] Additional publishers (GitHub Wiki, Obsidian)
1231
1243
 
1232
1244
  See [ROADMAP.md](./ROADMAP.md) for detailed planning.
package/RELEASE.md CHANGED
@@ -22,7 +22,7 @@ RepoLens uses semantic versioning:
22
22
  8. Push branch and tag: `git push --follow-tags`
23
23
  9. GitHub Actions `release.yml` runs automatically:
24
24
  - Security audit (dependency + secrets scanning)
25
- - Test suite (90 tests)
25
+ - Test suite (163 tests)
26
26
  - Create GitHub Release with tarball
27
27
  - Publish to npm (`npm publish --access public`)
28
28
  10. Verify on npm: `npm view @chappibunny/repolens version`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chappibunny/repolens",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "AI-assisted documentation intelligence system for technical and non-technical audiences",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -88,6 +88,38 @@ export const DOCUMENT_PLAN = [
88
88
  audience: "technical",
89
89
  ai: true,
90
90
  description: "Quick start guide for new developers"
91
+ },
92
+ {
93
+ key: "graphql_schema",
94
+ filename: "11-graphql-schema.md",
95
+ title: "GraphQL Schema",
96
+ audience: "technical",
97
+ ai: false,
98
+ description: "GraphQL types, queries, mutations, and resolver map"
99
+ },
100
+ {
101
+ key: "type_graph",
102
+ filename: "12-type-graph.md",
103
+ title: "TypeScript Type Graph",
104
+ audience: "technical",
105
+ ai: false,
106
+ description: "TypeScript interfaces, types, classes, and relationships"
107
+ },
108
+ {
109
+ key: "dependency_graph",
110
+ filename: "13-dependency-graph.md",
111
+ title: "Dependency Graph",
112
+ audience: "technical",
113
+ ai: false,
114
+ description: "Module dependency analysis with cycle detection"
115
+ },
116
+ {
117
+ key: "architecture_drift",
118
+ filename: "14-architecture-drift.md",
119
+ title: "Architecture Drift",
120
+ audience: "mixed",
121
+ ai: false,
122
+ description: "Structural changes compared to baseline snapshot"
91
123
  }
92
124
  ];
93
125
 
@@ -145,127 +145,251 @@ export async function generateDeveloperOnboarding(context) {
145
145
  // Fallback generators (deterministic, no AI)
146
146
 
147
147
  function getFallbackExecutiveSummary(context) {
148
+ const frameworkList = context.techStack.frameworks.join(", ") || "general-purpose";
149
+ const languageList = context.techStack.languages.join(", ") || "multiple languages";
150
+ const domainSummary = context.domains.slice(0, 5).map(d => d.name).join(", ");
151
+
148
152
  return `# Executive Summary
149
153
 
150
- ## What this system does
154
+ ## What This System Does
155
+
156
+ ${context.project.name} is a ${frameworkList} application built with ${languageList}. The codebase contains **${context.project.modulesDetected} modules** spread across **${context.project.filesScanned} files**, organized into ${context.domains.length} functional domain${context.domains.length === 1 ? "" : "s"}.
151
157
 
152
- ${context.project.name} is a ${context.techStack.frameworks.join(", ") || "software"} application with ${context.project.modulesDetected} modules across ${context.project.filesScanned} files.
158
+ ${context.project.apiRoutesDetected > 0 ? `The system exposes **${context.project.apiRoutesDetected} API endpoint${context.project.apiRoutesDetected === 1 ? "" : "s"}** and` : "It"} serves **${context.project.pagesDetected} application page${context.project.pagesDetected === 1 ? "" : "s"}** to end users.
153
159
 
154
- ## Main system areas
160
+ ## Primary Functional Areas
155
161
 
156
- The codebase is organized into ${context.domains.length} main domains:
162
+ The application is organized around the following business domains:
157
163
 
158
- ${context.domains.map(d => `- ${d.name}: ${d.moduleCount} modules`).join("\n")}
164
+ | Domain | Modules | Description |
165
+ |--------|---------|-------------|
166
+ ${context.domains.map(d => `| ${d.name} | ${d.moduleCount} | ${d.description || "—"} |`).join("\n")}
159
167
 
160
- ## Technology stack
168
+ ## Technology Profile
161
169
 
162
- - Frameworks: ${context.techStack.frameworks.join(", ") || "Not detected"}
163
- - Languages: ${context.techStack.languages.join(", ") || "Not detected"}
164
- - Build tools: ${context.techStack.buildTools.join(", ") || "Not detected"}
170
+ | Category | Details |
171
+ |----------|---------|
172
+ | Frameworks | ${context.techStack.frameworks.join(", ") || "Not detected"} |
173
+ | Languages | ${context.techStack.languages.join(", ") || "Not detected"} |
174
+ | Build Tools | ${context.techStack.buildTools.join(", ") || "Not detected"} |
165
175
 
166
- ## Key observations
176
+ ## Key Observations
167
177
 
168
- - ${context.project.pagesDetected} pages detected
169
- - ${context.project.apiRoutesDetected} API routes detected
170
- - Architecture patterns: ${context.patterns.join(", ") || "Standard patterns"}
178
+ The codebase follows ${context.patterns.length > 0 ? context.patterns.join(", ") : "standard"} architectural patterns. ${domainSummary ? `The core functional areas — ${domainSummary} — account for the majority of the application logic.` : ""}
171
179
 
172
- Note: AI-enhanced documentation is disabled. Enable with REPOLENS_AI_ENABLED=true for richer insights.`;
180
+ ---
181
+
182
+ *This summary is generated deterministically from repository structure. Enable AI enhancement (\`REPOLENS_AI_ENABLED=true\`) for natural language insights tailored to non-technical readers.*`;
173
183
  }
174
184
 
175
185
  function getFallbackSystemOverview(context) {
186
+ const sizeLabel = context.project.modulesDetected > 50 ? "large-scale" :
187
+ context.project.modulesDetected > 20 ? "medium-sized" : "focused";
188
+
176
189
  return `# System Overview
177
190
 
178
- ## Repository snapshot
191
+ ## Repository Snapshot
192
+
193
+ This is a ${sizeLabel} codebase organized into **${context.project.modulesDetected} modules** across **${context.project.filesScanned} files**.
194
+
195
+ | Metric | Value |
196
+ |--------|-------|
197
+ | Files scanned | ${context.project.filesScanned} |
198
+ | Modules | ${context.project.modulesDetected} |
199
+ | Application pages | ${context.project.pagesDetected} |
200
+ | API endpoints | ${context.project.apiRoutesDetected} |
201
+
202
+ ## Detected Patterns
179
203
 
180
- - Files scanned: ${context.project.filesScanned}
181
- - Modules: ${context.project.modulesDetected}
182
- - Pages: ${context.project.pagesDetected}
183
- - APIs: ${context.project.apiRoutesDetected}
204
+ ${context.patterns.length > 0 ? context.patterns.map(p => `- ${p}`).join("\n") : "No specific architectural patterns were detected. This typically means the project uses a straightforward directory-based organization."}
184
205
 
185
- ## Technology patterns
206
+ ## Dominant Domains
186
207
 
187
- ${context.patterns.map(p => `- ${p}`).join("\n")}
208
+ The following domains represent the largest areas of the codebase by file count:
188
209
 
189
- ## Dominant domains
210
+ | Rank | Domain | Files |
211
+ |------|--------|-------|
212
+ ${context.domains.slice(0, 5).map((d, i) => `| ${i + 1} | ${d.name} | ${d.fileCount} |`).join("\n")}
190
213
 
191
- ${context.domains.slice(0, 5).map((d, i) => `${i + 1}. ${d.name} (${d.fileCount} files)`).join("\n")}
214
+ ---
192
215
 
193
- Note: AI-enhanced documentation is disabled. Enable with REPOLENS_AI_ENABLED=true for richer insights.`;
216
+ *This overview is generated deterministically. Enable AI enhancement (\`REPOLENS_AI_ENABLED=true\`) for richer contextual explanations.*`;
194
217
  }
195
218
 
196
219
  function getFallbackBusinessDomains(context) {
197
220
  let output = `# Business Domains\n\n`;
221
+ output += `> This document maps the codebase into business-oriented functional areas. Each domain represents a distinct area of responsibility.\n\n`;
222
+ output += `**Total domains identified:** ${context.domains.length}\n\n`;
223
+ output += `---\n\n`;
198
224
 
199
225
  for (const domain of context.domains) {
200
- output += `## Domain: ${domain.name}\n\n`;
201
- output += `${domain.description}\n\n`;
202
- output += `Modules: ${domain.moduleCount}\n`;
203
- output += `Files: ${domain.fileCount}\n\n`;
204
- output += `Main modules:\n`;
205
- output += domain.topModules.slice(0, 5).map(m => `- ${m}`).join("\n");
206
- output += `\n\n`;
226
+ output += `## ${domain.name}\n\n`;
227
+ output += `${domain.description || "This domain covers a distinct functional area of the application."}\n\n`;
228
+ output += `| Metric | Value |\n`;
229
+ output += `|--------|-------|\n`;
230
+ output += `| Modules | ${domain.moduleCount} |\n`;
231
+ output += `| Files | ${domain.fileCount} |\n\n`;
232
+ if (domain.topModules?.length > 0) {
233
+ output += `**Key modules:** ${domain.topModules.slice(0, 5).map(m => `\`${m}\``).join(", ")}\n\n`;
234
+ }
207
235
  }
208
236
 
209
- output += `Note: AI-enhanced documentation is disabled. Enable with REPOLENS_AI_ENABLED=true for richer insights.`;
237
+ output += `---\n\n*Domain mapping is based on directory naming conventions. Enable AI enhancement (\`REPOLENS_AI_ENABLED=true\`) for natural language descriptions aimed at non-technical stakeholders.*`;
210
238
 
211
239
  return output;
212
240
  }
213
241
 
214
242
  function getFallbackArchitectureOverview(context) {
243
+ const patternDesc = context.patterns.length > 0
244
+ ? `The detected architectural patterns are **${context.patterns.join(", ")}**. These patterns shape how data and control flow through the system.`
245
+ : "No specific architectural patterns were detected. The project appears to follow a straightforward directory-based organization.";
246
+
215
247
  return `# Architecture Overview
216
248
 
217
- ## Architecture style
249
+ ## Architectural Style
250
+
251
+ ${patternDesc}
252
+
253
+ ## System Layers
218
254
 
219
- Based on detected patterns: ${context.patterns.join(", ")}
255
+ The codebase is organized into ${context.domains.length} functional layers, each encapsulating a distinct area of responsibility:
220
256
 
221
- ## Key layers
257
+ | Layer | Description |
258
+ |-------|-------------|
259
+ ${context.domains.slice(0, 8).map(d => `| **${d.name}** | ${d.description || "Handles a distinct functional concern"} |`).join("\n")}
222
260
 
223
- ${context.domains.slice(0, 5).map(d => `- ${d.name}: ${d.description}`).join("\n")}
261
+ ## Technology Stack
224
262
 
225
- ## Technology stack
263
+ | Category | Technologies |
264
+ |----------|-------------|
265
+ | Frameworks | ${context.techStack.frameworks.join(", ") || "Not detected"} |
266
+ | Languages | ${context.techStack.languages.join(", ") || "Not detected"} |
267
+ | Build Tools | ${context.techStack.buildTools.join(", ") || "Not detected"} |
226
268
 
227
- - Frameworks: ${context.techStack.frameworks.join(", ")}
228
- - Languages: ${context.techStack.languages.join(", ")}
229
- - Build tools: ${context.techStack.buildTools.join(", ")}
269
+ ## Scale & Complexity
230
270
 
231
- Note: AI-enhanced documentation is disabled. Enable with REPOLENS_AI_ENABLED=true for richer insights.`;
271
+ The repository comprises **${context.project.filesScanned} files** organized into **${context.project.modulesDetected} modules**. ${context.project.apiRoutesDetected > 0 ? `It exposes **${context.project.apiRoutesDetected} API endpoint${context.project.apiRoutesDetected === 1 ? "" : "s"}** and` : "It"} serves **${context.project.pagesDetected} application page${context.project.pagesDetected === 1 ? "" : "s"}**.
272
+
273
+ ---
274
+
275
+ *This architecture overview is generated deterministically. Enable AI enhancement (\`REPOLENS_AI_ENABLED=true\`) for deeper architectural narratives.*`;
232
276
  }
233
277
 
234
278
  function getFallbackDataFlows(flows) {
235
279
  let output = `# Data Flows\n\n`;
280
+ output += `> Data flows describe how information moves through the system — from external inputs through processing layers to storage or presentation.\n\n`;
281
+
282
+ if (!flows || flows.length === 0) {
283
+ output += `No data flows were detected. This typically means the system uses straightforward request–response patterns without distinct multi-step pipelines.\n\n`;
284
+ output += `---\n\n*Enable AI enhancement (\`REPOLENS_AI_ENABLED=true\`) for heuristic-based flow descriptions.*`;
285
+ return output;
286
+ }
287
+
288
+ output += `**${flows.length} flow${flows.length === 1 ? "" : "s"} detected** in the codebase.\n\n---\n\n`;
236
289
 
237
290
  for (const flow of flows) {
238
291
  output += `## ${flow.name}\n\n`;
239
292
  output += `${flow.description}\n\n`;
240
- output += `Steps:\n`;
241
- output += flow.steps.map((s, i) => `${i + 1}. ${s}`).join("\n");
242
- output += `\n\n`;
293
+ if (flow.steps && flow.steps.length > 0) {
294
+ output += `| Step | Action |\n`;
295
+ output += `|------|--------|\n`;
296
+ output += flow.steps.map((s, i) => `| ${i + 1} | ${s} |`).join("\n");
297
+ output += `\n\n`;
298
+ }
299
+ if (flow.modules && flow.modules.length > 0) {
300
+ output += `**Involved modules:** ${flow.modules.map(m => `\`${m}\``).join(", ")}\n\n`;
301
+ }
243
302
  }
244
303
 
245
- output += `Note: AI-enhanced documentation is disabled. Enable with REPOLENS_AI_ENABLED=true for richer insights.`;
304
+ output += `---\n\n*Flow detection is based on naming conventions and import patterns. Enable AI enhancement (\`REPOLENS_AI_ENABLED=true\`) for natural language flow narratives.*`;
246
305
 
247
306
  return output;
248
307
  }
249
308
 
250
309
  function getFallbackDeveloperOnboarding(context) {
310
+ const frameworkList = context.techStack.frameworks.join(", ") || "general-purpose tools";
311
+ const languageList = context.techStack.languages.join(", ") || "standard languages";
312
+
251
313
  return `# Developer Onboarding
252
314
 
253
- ## Start here
315
+ ## Welcome
316
+
317
+ This guide helps new contributors get oriented in the **${context.project.name}** repository. The project is built with ${frameworkList} and ${languageList}, containing **${context.project.modulesDetected} modules** across **${context.project.filesScanned} files**.
318
+
319
+ ## Repository Structure
320
+
321
+ The top-level directory is organized as follows:
254
322
 
255
- This is a ${context.project.name} repository with ${context.project.modulesDetected} modules.
323
+ | Directory | Purpose |
324
+ |-----------|---------|
325
+ ${context.repoRoots.map(root => `| \`${root}\` | ${describeRoot(root)} |`).join("\n")}
256
326
 
257
- ## Main folders
327
+ ## Technology Stack
258
328
 
259
- ${context.repoRoots.map(root => `- ${root}`).join("\n")}
329
+ | Category | Technologies |
330
+ |----------|-------------|
331
+ | Frameworks | ${context.techStack.frameworks.join(", ") || "Not detected"} |
332
+ | Languages | ${context.techStack.languages.join(", ") || "Not detected"} |
333
+ | Build Tools | ${context.techStack.buildTools.join(", ") || "Not detected"} |
260
334
 
261
- ## Technology stack
335
+ ## Largest Modules
262
336
 
263
- - ${context.techStack.frameworks.join(", ")}
264
- - ${context.techStack.languages.join(", ")}
337
+ These are the primary modules by file count — good starting points for understanding the system:
265
338
 
266
- ## Top modules by size
339
+ | Module | Files | Description |
340
+ |--------|-------|-------------|
341
+ ${context.topModules.slice(0, 10).map((m, i) => `| \`${m.key}\` | ${m.fileCount} | ${describeOnboardingModule(m.key)} |`).join("\n")}
267
342
 
268
- ${context.topModules.slice(0, 10).map((m, i) => `${i + 1}. ${m.key} (${m.fileCount} files)`).join("\n")}
343
+ ## Getting Started
344
+
345
+ 1. Clone the repository and install dependencies
346
+ 2. Review the top-level directories above to understand the project layout
347
+ 3. Start with the largest modules listed above — they contain the core functionality
348
+ 4. Check for a \`README.md\` or \`CONTRIBUTING.md\` file for project-specific setup instructions
349
+
350
+ ---
351
+
352
+ *This onboarding guide is generated deterministically. Enable AI enhancement (\`REPOLENS_AI_ENABLED=true\`) for a narrative-style guide with tips and common pitfalls.*`;
353
+ }
354
+
355
+ function describeRoot(root) {
356
+ const lower = root.toLowerCase().replace(/\/$/, "");
357
+ if (/^src$|^lib$/.test(lower)) return "Application source code";
358
+ if (/^test|^__test|^spec/.test(lower)) return "Test suites";
359
+ if (/^doc/.test(lower)) return "Documentation";
360
+ if (/^bin$|^scripts?$/.test(lower)) return "CLI entry points and scripts";
361
+ if (/^config/.test(lower)) return "Configuration files";
362
+ if (/^public$|^static$|^assets$/.test(lower)) return "Static assets";
363
+ if (/^dist$|^build$|^out$/.test(lower)) return "Build output";
364
+ if (/^\.github$/.test(lower)) return "GitHub Actions and workflows";
365
+ if (/^api$/.test(lower)) return "API definitions";
366
+ if (/^components?$/.test(lower)) return "Shared UI components";
367
+ if (/^pages?$|^views?$|^screens?$/.test(lower)) return "Application pages/views";
368
+ if (/^utils?$|^helpers?$/.test(lower)) return "Utility functions";
369
+ if (/^services?$/.test(lower)) return "Service layer";
370
+ if (/^hooks?$/.test(lower)) return "Custom hooks";
371
+ return "Project files";
372
+ }
269
373
 
270
- Note: AI-enhanced documentation is disabled. Enable with REPOLENS_AI_ENABLED=true for richer insights.`;
374
+ function describeOnboardingModule(key) {
375
+ const lower = key.toLowerCase();
376
+ if (/auth/.test(lower)) return "Authentication and authorization logic";
377
+ if (/api|route|endpoint/.test(lower)) return "API layer and route handlers";
378
+ if (/component|widget|ui/.test(lower)) return "User interface components";
379
+ if (/hook/.test(lower)) return "Custom hooks and shared state logic";
380
+ if (/util|helper|lib/.test(lower)) return "Utility and helper functions";
381
+ if (/service/.test(lower)) return "Service layer / business logic";
382
+ if (/model|schema|entity/.test(lower)) return "Data models and schemas";
383
+ if (/config|setting/.test(lower)) return "Configuration management";
384
+ if (/test|spec/.test(lower)) return "Test infrastructure";
385
+ if (/style|css|theme/.test(lower)) return "Styling and theming";
386
+ if (/page|view|screen/.test(lower)) return "Application pages and views";
387
+ if (/store|state|redux/.test(lower)) return "State management";
388
+ if (/middleware/.test(lower)) return "Request/response middleware";
389
+ if (/database|db|migration/.test(lower)) return "Database layer";
390
+ if (/render/.test(lower)) return "Rendering and template logic";
391
+ if (/publish/.test(lower)) return "Publishing and output delivery";
392
+ if (/scan/.test(lower)) return "File and repository scanning";
393
+ if (/analyz/.test(lower)) return "Code analysis and inference";
394
+ return "Core application module";
271
395
  }