@chappibunny/repolens 0.8.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,29 @@
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
+
5
28
  ## 0.8.0
6
29
 
7
30
  ### ✨ 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.8.0 — Extended Analysis
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
 
@@ -228,7 +228,7 @@ npm link
228
228
  Install from a specific version:
229
229
 
230
230
  ```bash
231
- npm install https://github.com/CHAPIBUNNY/repolens/releases/download/v0.8.0/chappibunny-repolens-0.8.0.tgz
231
+ npm install https://github.com/CHAPIBUNNY/repolens/releases/download/v0.9.0/chappibunny-repolens-0.9.0.tgz
232
232
  ```
233
233
  </details>
234
234
 
@@ -1070,7 +1070,7 @@ npm test
1070
1070
  - Integration workflows
1071
1071
  - Doctor command validation
1072
1072
 
1073
- **Coverage:** 90 tests passing across 11 test files
1073
+ **Coverage:** 163 tests passing across 14 test files
1074
1074
 
1075
1075
  ### Test Package Installation Locally
1076
1076
 
@@ -1081,7 +1081,7 @@ Simulates the full user installation experience:
1081
1081
  npm pack
1082
1082
 
1083
1083
  # Install globally from tarball
1084
- npm install -g chappibunny-repolens-0.8.0.tgz
1084
+ npm install -g chappibunny-repolens-0.9.0.tgz
1085
1085
 
1086
1086
  # Verify
1087
1087
  repolens --version
@@ -1146,7 +1146,7 @@ repolens/
1146
1146
  │ ├── telemetry.js # Opt-in error tracking + performance timers
1147
1147
  │ ├── errors.js # Enhanced error messages with guidance
1148
1148
  │ └── update-check.js # Version update notifications
1149
- ├── tests/ # Vitest test suite (121 tests across 12 files)
1149
+ ├── tests/ # Vitest test suite (163 tests across 14 files)
1150
1150
  ├── .repolens.yml # Dogfooding config
1151
1151
  ├── package.json
1152
1152
  ├── CHANGELOG.md
@@ -1163,13 +1163,13 @@ RepoLens uses automated GitHub Actions releases.
1163
1163
  ### Creating a Release
1164
1164
 
1165
1165
  ```bash
1166
- # Patch version (0.8.0 → 0.8.1) - Bug fixes
1166
+ # Patch version (0.9.0 → 0.9.1) - Bug fixes
1167
1167
  npm run release:patch
1168
1168
 
1169
- # Minor version (0.8.0 → 0.9.0) - New features
1169
+ # Minor version (0.9.0 → 0.10.0) - New features
1170
1170
  npm run release:minor
1171
1171
 
1172
- # Major version (0.8.0 → 1.0.0) - Breaking changes
1172
+ # Major version (0.9.0 → 1.0.0) - Breaking changes
1173
1173
  npm run release:major
1174
1174
 
1175
1175
  # Push the tag to trigger workflow
@@ -1201,7 +1201,7 @@ RepoLens is currently in early access. v1.0 will open for community contribution
1201
1201
 
1202
1202
  ## 🗺️ Roadmap to v1.0
1203
1203
 
1204
- **Current Status:** v0.8.0 — Extended Analysis
1204
+ **Current Status:** v0.9.0 — Plugin System
1205
1205
 
1206
1206
  ### Completed ✅
1207
1207
 
@@ -1217,7 +1217,7 @@ RepoLens is currently in early access. v1.0 will open for community contribution
1217
1217
  - [x] GitHub Actions automation (publish + release)
1218
1218
  - [x] PR architecture diff comments
1219
1219
  - [x] Performance guardrails (10k warning, 50k limit)
1220
- - [x] Comprehensive test suite (121 tests across 12 files)
1220
+ - [x] Comprehensive test suite (163 tests across 14 files)
1221
1221
  - [x] Security hardening (secret detection, injection prevention, fuzzing)
1222
1222
  - [x] Discord notifications with rich embeds
1223
1223
  - [x] Documentation coverage & health scoring
@@ -1234,10 +1234,11 @@ RepoLens is currently in early access. v1.0 will open for community contribution
1234
1234
  - [x] TypeScript type graph analysis (interfaces, classes, relationships)
1235
1235
  - [x] Dependency graph with circular dependency detection
1236
1236
  - [x] Architecture drift detection (baseline comparison)
1237
+ - [x] Plugin system for custom renderers and publishers
1237
1238
 
1238
1239
  ### Planned for v1.0 🎯
1239
1240
 
1240
- - [ ] Plugin system for custom renderers
1241
+ - [ ] Stability audit: freeze CLI flags and config schema
1241
1242
  - [ ] Additional publishers (GitHub Wiki, Obsidian)
1242
1243
 
1243
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.8.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",
@@ -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
  }
package/src/cli.js CHANGED
@@ -21,11 +21,13 @@ import { upsertPrComment } from "./delivery/comment.js";
21
21
  import { runInit } from "./init.js";
22
22
  import { runMigrate } from "./migrate.js";
23
23
  import { runWatch } from "./watch.js";
24
- import { info, error } from "./utils/logger.js";
24
+ import { info, error, warn } from "./utils/logger.js";
25
25
  import { formatError } from "./utils/errors.js";
26
26
  import { checkForUpdates } from "./utils/update-check.js";
27
27
  import { generateDocumentSet } from "./docs/generate-doc-set.js";
28
28
  import { writeDocumentSet } from "./docs/write-doc-set.js";
29
+ import { loadPlugins } from "./plugins/loader.js";
30
+ import { PluginManager } from "./plugins/manager.js";
29
31
  import {
30
32
  initTelemetry,
31
33
  captureError,
@@ -313,6 +315,19 @@ async function main() {
313
315
  process.exit(2);
314
316
  }
315
317
 
318
+ // Load plugins
319
+ let pluginManager;
320
+ try {
321
+ const plugins = await loadPlugins(cfg.plugins, cfg.__repoRoot);
322
+ pluginManager = new PluginManager(plugins);
323
+ if (pluginManager.hasPlugins()) {
324
+ info(`Loaded ${pluginManager.count} plugin(s): ${pluginManager.names.join(", ")}`);
325
+ }
326
+ } catch (err) {
327
+ warn(`Plugin loading failed: ${err.message}`);
328
+ pluginManager = new PluginManager([]);
329
+ }
330
+
316
331
  try {
317
332
  info("Scanning repository...");
318
333
  const scanTimer = startTimer("scan");
@@ -336,7 +351,7 @@ async function main() {
336
351
  try {
337
352
  info("Generating documentation set...");
338
353
  const renderTimer = startTimer("render");
339
- const docSet = await generateDocumentSet(scan, cfg, rawDiff);
354
+ const docSet = await generateDocumentSet(scan, cfg, rawDiff, pluginManager);
340
355
  stopTimer(renderTimer);
341
356
 
342
357
  info("Writing documentation to disk...");
@@ -353,7 +368,7 @@ async function main() {
353
368
 
354
369
  info("Publishing documentation...");
355
370
  const publishTimer = startTimer("publish_docs");
356
- await publishDocs(cfg, renderedPages, scan);
371
+ await publishDocs(cfg, renderedPages, scan, pluginManager);
357
372
  stopTimer(publishTimer);
358
373
 
359
374
  await upsertPrComment(diffData);
@@ -73,15 +73,27 @@ export function validateConfig(config) {
73
73
  errors.push("publishers array cannot be empty");
74
74
  } else {
75
75
  config.publishers.forEach((pub, idx) => {
76
- if (!SUPPORTED_PUBLISHERS.includes(pub)) {
77
- errors.push(
78
- `publishers[${idx}]: "${pub}" is not a valid publisher. ` +
79
- `Supported: ${SUPPORTED_PUBLISHERS.join(", ")}`
80
- );
76
+ if (typeof pub !== "string" || pub.length === 0) {
77
+ errors.push(`publishers[${idx}]: must be a non-empty string`);
81
78
  }
79
+ // Core publishers are validated strictly; plugin publishers are allowed
80
+ // as long as they are strings (validated at plugin load time)
82
81
  });
83
82
  }
84
83
 
84
+ // Validate plugins (optional)
85
+ if (config.plugins !== undefined) {
86
+ if (!Array.isArray(config.plugins)) {
87
+ errors.push("plugins must be an array");
88
+ } else {
89
+ config.plugins.forEach((p, idx) => {
90
+ if (typeof p !== "string" || p.length === 0) {
91
+ errors.push(`plugins[${idx}]: must be a non-empty string (path or package name)`);
92
+ }
93
+ });
94
+ }
95
+ }
96
+
85
97
  // Validate scan section
86
98
  if (!config.scan) {
87
99
  errors.push("Missing required section: scan");
@@ -29,7 +29,7 @@ import {
29
29
  import { info } from "../utils/logger.js";
30
30
  import path from "node:path";
31
31
 
32
- export async function generateDocumentSet(scanResult, config, diffData = null) {
32
+ export async function generateDocumentSet(scanResult, config, diffData = null, pluginManager = null) {
33
33
  info("Building structured context for AI...");
34
34
 
35
35
  // Build AI context from scan results
@@ -70,13 +70,19 @@ export async function generateDocumentSet(scanResult, config, diffData = null) {
70
70
  drift: driftResult,
71
71
  };
72
72
 
73
+ // Run afterScan hook
74
+ let hookScanResult = scanResult;
75
+ if (pluginManager) {
76
+ hookScanResult = await pluginManager.runHook("afterScan", scanResult);
77
+ }
78
+
73
79
  // Generate each document
74
80
  for (const docPlan of activeDocuments) {
75
81
  let content = null;
76
82
 
77
83
  try {
78
84
  content = await generateDocument(docPlan, {
79
- scanResult,
85
+ scanResult: hookScanResult,
80
86
  config,
81
87
  aiContext,
82
88
  moduleContext,
@@ -86,6 +92,7 @@ export async function generateDocumentSet(scanResult, config, diffData = null) {
86
92
  tsResult,
87
93
  depGraph,
88
94
  driftResult,
95
+ pluginManager,
89
96
  });
90
97
 
91
98
  documents.push({
@@ -100,7 +107,52 @@ export async function generateDocumentSet(scanResult, config, diffData = null) {
100
107
  info(`✗ Failed to generate ${docPlan.filename}: ${error.message}`);
101
108
  }
102
109
  }
103
-
110
+
111
+ // Generate plugin-provided documents (not in core document plan)
112
+ if (pluginManager) {
113
+ const pluginRenderers = pluginManager.getRenderers();
114
+ const coreKeys = new Set(activeDocuments.map(d => d.key));
115
+
116
+ for (const [key, renderer] of Object.entries(pluginRenderers)) {
117
+ if (coreKeys.has(key)) continue; // Already generated by core
118
+
119
+ try {
120
+ const content = await renderer.render({
121
+ scanResult: hookScanResult,
122
+ config,
123
+ aiContext,
124
+ moduleContext,
125
+ flows,
126
+ diffData,
127
+ graphqlResult,
128
+ tsResult,
129
+ depGraph,
130
+ driftResult,
131
+ });
132
+
133
+ documents.push({
134
+ key,
135
+ title: renderer.title,
136
+ filename: renderer.filename || `${key}.md`,
137
+ category: renderer.category || "custom",
138
+ audience: renderer.audience || ["technical"],
139
+ content,
140
+ generated: new Date().toISOString(),
141
+ });
142
+
143
+ info(`✓ Generated plugin document: ${renderer.title}`);
144
+ } catch (err) {
145
+ info(`✗ Failed to generate plugin document "${key}": ${err.message}`);
146
+ }
147
+ }
148
+ }
149
+
150
+ // Run afterRender hook
151
+ if (pluginManager) {
152
+ const rendered = await pluginManager.runHook("afterRender", documents);
153
+ return { documents: rendered, artifacts, config };
154
+ }
155
+
104
156
  return {
105
157
  documents,
106
158
  artifacts,
@@ -110,7 +162,7 @@ export async function generateDocumentSet(scanResult, config, diffData = null) {
110
162
 
111
163
  async function generateDocument(docPlan, context) {
112
164
  const { key } = docPlan;
113
- const { scanResult, config, aiContext, moduleContext, flows, diffData, graphqlResult, tsResult, depGraph, driftResult } = context;
165
+ const { scanResult, config, aiContext, moduleContext, flows, diffData, graphqlResult, tsResult, depGraph, driftResult, pluginManager } = context;
114
166
 
115
167
  switch (key) {
116
168
  case "executive_summary":
@@ -165,7 +217,15 @@ async function generateDocument(docPlan, context) {
165
217
  case "architecture_drift":
166
218
  return renderDriftReport(driftResult);
167
219
 
168
- default:
220
+ default: {
221
+ // Check if a plugin provides this renderer
222
+ if (pluginManager) {
223
+ const pluginRenderers = pluginManager.getRenderers();
224
+ if (pluginRenderers[key]) {
225
+ return await pluginRenderers[key].render(context);
226
+ }
227
+ }
169
228
  throw new Error(`Unknown document type: ${key}`);
229
+ }
170
230
  }
171
231
  }