@chappibunny/repolens 0.4.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.
package/README.md ADDED
@@ -0,0 +1,899 @@
1
+ ```
2
+ ██████╗ ███████╗██████╗ ██████╗ ██╗ ███████╗███╗ ██╗███████╗
3
+ ██╔══██╗██╔════╝██╔══██╗██╔═══██╗██║ ██╔════╝████╗ ██║██╔════╝
4
+ ██████╔╝█████╗ ██████╔╝██║ ██║██║ █████╗ ██╔██╗ ██║███████╗
5
+ ██╔══██╗██╔══╝ ██╔═══╝ ██║ ██║██║ ██╔══╝ ██║╚██╗██║╚════██║
6
+ ██║ ██║███████╗██║ ╚██████╔╝███████╗███████╗██║ ╚████║███████║
7
+ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═══╝╚══════╝
8
+ 🔍 Repository Intelligence CLI 📊
9
+ ```
10
+
11
+ AI-assisted documentation intelligence system that generates architecture docs for engineers AND readable system docs for stakeholders
12
+
13
+ **Current Status**: v0.4.0 — Production Ready
14
+
15
+ 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.
16
+
17
+ ⚠️ **Early Access Notice**: The CLI commands and configuration format may evolve until v1.0. We will provide migration guides for any breaking changes. v1.0 will guarantee stable CLI behavior and config schema.
18
+
19
+ ---
20
+
21
+ ## 🚀 Quick Start (60 seconds)
22
+
23
+ **Step 1: Install**
24
+ ```bash
25
+ npm install github:CHAPIBUNNY/repolens
26
+ ```
27
+
28
+ **Step 2: Initialize** (creates config + GitHub Actions workflow)
29
+ ```bash
30
+ npx repolens init
31
+ ```
32
+
33
+ **Step 3: Configure Notion** (optional, skip if using Markdown only)
34
+ ```bash
35
+ # Edit .env and add:
36
+ NOTION_TOKEN=secret_xxx
37
+ NOTION_PARENT_PAGE_ID=xxx
38
+ ```
39
+
40
+ **Step 4: Publish**
41
+ ```bash
42
+ npx repolens publish
43
+ ```
44
+
45
+ **Done!** Your docs are now live in Notion and/or `.repolens/` directory.
46
+
47
+ **🔄 Upgrading from v0.3.0 or earlier?**
48
+ Run `npx repolens migrate` to automatically update your workflow files. See [MIGRATION.md](MIGRATION.md) for details.
49
+
50
+ ---
51
+
52
+ ---
53
+
54
+ ## 🎯 What RepoLens Does
55
+
56
+ RepoLens transforms repositories into documented, understandable systems with **AI-assisted documentation intelligence**:
57
+
58
+ ### 🤖 Two Output Modes
59
+
60
+ **Deterministic Mode (Default)**
61
+ - Fast, free, always reliable
62
+ - Generates technical documentation from repository structure
63
+ - Perfect for code inventories and reference docs
64
+
65
+ **AI-Enhanced Mode (Optional)**
66
+ - Adds natural language explanations and insights
67
+ - Creates audience-specific documentation (technical + non-technical)
68
+ - Understands business context and data flows
69
+ - Provider-agnostic (OpenAI, Anthropic, Azure, local models)
70
+
71
+ ### 📋 Documentation Types
72
+
73
+ **Non-Technical Documents** (readable by founders, PMs, ops):
74
+ - **Executive Summary** — Project overview, capabilities, tech summary
75
+ - **Business Domains** — What the system does by functional area
76
+ - **Data Flows** — How information moves through the system
77
+
78
+ **Mixed-Audience Documents** (useful for everyone):
79
+ - **System Overview** — Tech stack, scale, module inventory
80
+ - **Developer Onboarding** — How to get started contributing
81
+ - **Change Impact** — Architecture diff with context
82
+
83
+ **Technical Documents** (engineers only):
84
+ - **Architecture Overview** — Layered technical analysis
85
+ - **Module Catalog** — Complete code inventory with patterns
86
+ - **API Surface** — REST endpoints, methods, routes
87
+ - **Route Map** — Frontend routes and pages
88
+ - **System Map** — Visual architecture diagrams
89
+
90
+ ### 🔍 Smart Detection
91
+
92
+ RepoLens automatically detects:
93
+ - **Frameworks**: Next.js, React, Vue, Express, NestJS, and more
94
+ - **Languages**: TypeScript, JavaScript
95
+ - **Build Tools**: Vite, Webpack, Turbo, esbuild
96
+ - **Testing**: Vitest, Jest, Playwright, Cypress
97
+ - **Business Domains**: Authentication, Market Data, Payments, Content, etc.
98
+ - **Data Flows**: How information moves through your system
99
+ - **Architectural Patterns**: Module relationships and dependencies
100
+
101
+ ### ✨ Key Features
102
+
103
+ ✅ **AI-Assisted Documentation** - Optional AI layer for natural language explanations
104
+ ✅ **Multi-Audience Output** - Technical docs for engineers + readable docs for stakeholders
105
+ ✅ **Zero Hallucination Policy** - AI receives only structured context, never raw code
106
+ ✅ **Provider Agnostic** - Works with any OpenAI-compatible API
107
+ ✅ **Deterministic Fallback** - Always generates docs even if AI unavailable
108
+ ✅ **Business Domain Inference** - Automatically maps code to business functions
109
+ ✅ **Data Flow Analysis** - Understands how information moves through your system
110
+ ✅ **Multiple Publishers** - Output to Notion, Markdown, or both
111
+ ✅ **Branch-Aware** - Prevent doc conflicts across branches
112
+ ✅ **GitHub Actions** - Autonomous operation on every push
113
+
114
+ ---
115
+
116
+ ## 📦 Installation
117
+
118
+ ### Recommended: GitHub Install
119
+
120
+ ```bash
121
+ npm install github:CHAPIBUNNY/repolens
122
+ ```
123
+
124
+ This installs directly from the latest GitHub commit. Perfect for early access.
125
+
126
+ ### Alternative Methods
127
+
128
+ <details>
129
+ <summary><b>Option B: Local Development</b></summary>
130
+
131
+ Clone and link for development:
132
+
133
+ ```bash
134
+ git clone https://github.com/CHAPIBUNNY/repolens.git
135
+ cd repolens
136
+ npm link
137
+ ```
138
+ </details>
139
+
140
+ <details>
141
+ <summary><b>Option C: GitHub Release Tarball</b></summary>
142
+
143
+ Install from a specific version:
144
+
145
+ ```bash
146
+ npm install https://github.com/CHAPIBUNNY/repolens/releases/download/v0.2.0/repolens-0.2.0.tgz
147
+ ```
148
+ </details>
149
+
150
+ <details>
151
+ <summary><b>Option D: npm Registry (Coming v1.0)</b></summary>
152
+
153
+ Once published to npm:
154
+
155
+ ```bash
156
+ npm install -g repolens
157
+ ```
158
+ </details>
159
+
160
+ ---
161
+
162
+ ## 🎓 Complete Onboarding Guide
163
+
164
+ ### Step 1: Initialize RepoLens
165
+
166
+ Run this in your project root:
167
+
168
+ ```bash
169
+ npx repolens init
170
+ ```
171
+
172
+ **What it creates:**
173
+ - `.repolens.yml` — Configuration file
174
+ - `.github/workflows/repolens.yml` — Auto-publishing workflow
175
+ - `.env.example` — Environment variable template
176
+ - `README.repolens.md` — Quick reference guide
177
+
178
+ **Default configuration works for:**
179
+ - Next.js projects
180
+ - React applications
181
+ - Node.js backends
182
+ - Monorepos with common structure
183
+
184
+ ### Step 2: Configure Publishers
185
+
186
+ Open `.repolens.yml` and verify the `publishers` section:
187
+
188
+ ```yaml
189
+ publishers:
190
+ - markdown # Always works, no setup needed
191
+ - notion # Requires NOTION_TOKEN and NOTION_PARENT_PAGE_ID
192
+ ```
193
+
194
+ **Markdown Only** (simplest):
195
+ ```yaml
196
+ publishers:
197
+ - markdown
198
+ ```
199
+ Documentation lands in `.repolens/` directory. Commit these files or ignore them.
200
+
201
+ **Notion + Markdown** (recommended):
202
+ ```yaml
203
+ publishers:
204
+ - notion
205
+ - markdown
206
+ ```
207
+ Docs published to Notion for team visibility, plus local Markdown backups.
208
+
209
+ ### Step 3: Enable AI Features (Optional)
210
+
211
+ **AI-enhanced documentation adds natural language explanations for non-technical audiences.**
212
+
213
+ **3.1: Choose an AI Provider**
214
+
215
+ RepoLens works with any OpenAI-compatible API:
216
+ - **OpenAI** (gpt-4-turbo-preview, gpt-3.5-turbo)
217
+ - **Anthropic Claude** (via API gateway)
218
+ - **Azure OpenAI** (enterprise deployments)
219
+ - **Local Models** (Ollama, LM Studio, etc.)
220
+
221
+ **3.2: Add Environment Variables**
222
+
223
+ Create `.env` in your project root:
224
+ ```bash
225
+ # Enable AI features
226
+ REPOLENS_AI_ENABLED=true
227
+ REPOLENS_AI_API_KEY=sk-xxxxxxxxxxxxx
228
+
229
+ # Optional: Customize provider
230
+ REPOLENS_AI_BASE_URL=https://api.openai.com/v1
231
+ REPOLENS_AI_MODEL=gpt-4-turbo-preview
232
+ REPOLENS_AI_TEMPERATURE=0.3
233
+ REPOLENS_AI_MAX_TOKENS=2000
234
+ ```
235
+
236
+ **3.3: Configure AI in .repolens.yml**
237
+
238
+ ```yaml
239
+ ai:
240
+ enabled: true # Enable AI features
241
+ mode: hybrid # hybrid, full, or off
242
+ temperature: 0.3 # Lower = more focused (0.0-1.0)
243
+ max_tokens: 2000 # Token limit per request
244
+
245
+ features:
246
+ executive_summary: true # Non-technical overview
247
+ business_domains: true # Functional area descriptions
248
+ architecture_overview: true # Layered technical analysis
249
+ data_flows: true # System data flow explanations
250
+ developer_onboarding: true # Getting started guide
251
+ change_impact: true # Architecture diff with context
252
+ ```
253
+
254
+ **Cost Estimates** (with gpt-4-turbo-preview):
255
+ - Small repo (<50 files): $0.10-$0.30 per run
256
+ - Medium repo (50-200 files): $0.30-$0.80 per run
257
+ - Large repo (200+ files): $0.80-$2.00 per run
258
+
259
+ **For GitHub Actions**, add as repository secret:
260
+ - Name: `AI_KEY`, Value: `sk-xxxxx` (your OpenAI API key)
261
+
262
+ See [AI.md](AI.md) for complete AI documentation and provider setup.
263
+
264
+ ### Step 4: Set Up Notion Integration (Optional)
265
+
266
+ If using the Notion publisher:
267
+
268
+ **4.1: Create Notion Integration**
269
+ 1. Go to [notion.so/my-integrations](https://www.notion.so/my-integrations)
270
+ 2. Click **"+ New Integration"**
271
+ 3. Name it **"RepoLens"**
272
+ 4. Select your workspace
273
+ 5. Copy the **Internal Integration Token** (starts with `secret_`)
274
+
275
+ **4.2: Create Parent Page**
276
+ 1. Create a new page in Notion (e.g., "📚 Architecture Docs")
277
+ 2. Click **"..."** menu → **"Add connections"** → Select **"RepoLens"**
278
+ 3. Copy the page URL: `https://notion.so/workspace/PAGE_ID?xxx`
279
+ 4. Extract the `PAGE_ID` (32-character hex string)
280
+
281
+ **4.3: Add Environment Variables**
282
+
283
+ **For Local Development:**
284
+ Create `.env` in your project root:
285
+ ```bash
286
+ NOTION_TOKEN=secret_xxxxxxxxxxxxx
287
+ NOTION_PARENT_PAGE_ID=xxxxxxxxxxxxx
288
+ NOTION_VERSION=2022-06-28
289
+ ```
290
+
291
+ **For GitHub Actions:**
292
+ Add as repository secrets:
293
+ 1. Go to your repo → **Settings** → **Secrets and variables** → **Actions**
294
+ 2. Click **"New repository secret"**
295
+ 3. Add:
296
+ - Name: `NOTION_TOKEN`, Value: `secret_xxxxx`
297
+ - Name: `NOTION_PARENT_PAGE_ID`, Value: `xxxxxx`
298
+
299
+ ### Step 5: Configure Branch Publishing (Recommended)
300
+
301
+ Prevent documentation conflicts by limiting which branches publish to Notion:
302
+
303
+ ```yaml
304
+ notion:
305
+ branches:
306
+ - main # Only main branch publishes
307
+ includeBranchInTitle: false # Clean titles (no [branch-name] suffix)
308
+ ```
309
+
310
+ **Options:**
311
+ - `branches: [main]` — Only main publishes (recommended)
312
+ - `branches: [main, staging, release/*]` — Multiple branches with glob support
313
+ - Omit `branches` entirely — All branches publish (may cause conflicts)
314
+
315
+ **Markdown publisher always runs on all branches** (local files don't conflict).
316
+
317
+ ### Step 6: Customize Scan Patterns (Optional)
318
+
319
+ Adjust what files RepoLens scans:
320
+
321
+ ```yaml
322
+ scan:
323
+ include:
324
+ - "src/**/*.{ts,tsx,js,jsx}"
325
+ - "app/**/*.{ts,tsx,js,jsx}"
326
+ - "lib/**/*.{ts,tsx,js,jsx}"
327
+ ignore:
328
+ - "node_modules/**"
329
+ - ".next/**"
330
+ - "dist/**"
331
+ - "build/**"
332
+
333
+ module_roots:
334
+ - "src"
335
+ - "app"
336
+ - "lib"
337
+ ```
338
+
339
+ **Performance Note:** RepoLens warns at 10k files and limits at 50k files.
340
+
341
+ ### Step 7: Generate Documentation
342
+
343
+ Run locally to test:
344
+
345
+ ```bash
346
+ npx repolens publish
347
+ ```
348
+
349
+ **Expected output:**
350
+ ```
351
+ RepoLens v0.2.0
352
+ ────────────────────────────────────────
353
+ [RepoLens] Using config: /path/to/.repolens.yml
354
+ [RepoLens] Loading configuration...
355
+ [RepoLens] Scanning repository...
356
+ [RepoLens] Detected 42 modules
357
+ [RepoLens] Publishing documentation...
358
+ [RepoLens] Publishing to Notion from branch: main
359
+ [RepoLens] ✓ System Overview published
360
+ [RepoLens] ✓ Module Catalog published
361
+ [RepoLens] ✓ API Surface published
362
+ [RepoLens] ✓ Route Map published
363
+ [RepoLens] ✓ System Map published
364
+ ```
365
+
366
+ ### Step 8: Verify Output
367
+
368
+ **Markdown Output:****
369
+ ```bash
370
+ ls .repolens/
371
+ # system_overview.md
372
+ # module_catalog.md
373
+ # api_surface.md
374
+ # route_map.md
375
+ # system_map.md
376
+ # diagrams/system_map.svg
377
+ ```
378
+
379
+ **Notion Output:**
380
+ Open your Notion parent page and verify child pages were created:
381
+ - 📊 RepoLens — Executive Summary (if AI enabled)
382
+ - 📈 RepoLens — Business Domains (if AI enabled)
383
+ - 📊 RepoLens — System Overview
384
+ - 📚 RepoLens — Developer Onboarding (if AI enabled)
385
+ - 📊 RepoLens — Architecture Overview (if AI enabled)
386
+ - 📊 RepoLens — Data Flows (if AI enabled)
387
+ - 📌 RepoLens — Module Catalog
388
+ - 🔌 RepoLens — API Surface
389
+ - 🗺️ RepoLens — Route Map
390
+ - 🏛️ RepoLens — System Map
391
+
392
+ ### Step 9: Enable GitHub Actions (Automatic Updates)
393
+
394
+ **Commit the workflow:**
395
+ ```bash
396
+ git add .github/workflows/repolens.yml .repolens.yml
397
+ git commit -m "Add RepoLens documentation automation"
398
+ git push
399
+ ```
400
+
401
+ **What happens next:**
402
+ - ✅ Every push to `main` regenerates docs
403
+ - ✅ Pull requests get architecture diff comments
404
+ - ✅ Documentation stays evergreen automatically
405
+
406
+ **Pro Tip:** Add `.repolens/` to `.gitignore` if you don't want to commit local Markdown files (Notion publisher is your source of truth).
407
+
408
+ ---
409
+
410
+ ## 🎮 Usage Commands
411
+
412
+ ### Publish Documentation
413
+
414
+ Auto-discovers `.repolens.yml`:
415
+ ```bash
416
+ npx repolens publish
417
+ ```
418
+
419
+ Specify config path explicitly:
420
+ ```bash
421
+ npx repolens publish --config /path/to/.repolens.yml
422
+ ```
423
+
424
+ Via npm script (add to package.json):
425
+ ```json
426
+ {
427
+ "scripts": {
428
+ "docs": "repolens publish"
429
+ }
430
+ }
431
+ ```
432
+
433
+ ### Validate Setup
434
+
435
+ Check if your RepoLens setup is valid:
436
+
437
+ ```bash
438
+ npx repolens doctor
439
+ ```
440
+
441
+ Validates:
442
+ - ✅ `.repolens.yml` exists and is valid YAML
443
+ - ✅ Required config fields present
444
+ - ✅ Publishers configured correctly
445
+ - ✅ Scan patterns defined
446
+ - ✅ Mermaid CLI installation status
447
+
448
+ ### Migrate Workflows
449
+
450
+ **🚨 Upgrading from v0.3.0 or earlier?** Automatically update your GitHub Actions workflows:
451
+
452
+ ```bash
453
+ npx repolens migrate
454
+ ```
455
+
456
+ Preview changes without applying:
457
+ ```bash
458
+ npx repolens migrate --dry-run
459
+ ```
460
+
461
+ What it fixes:
462
+ - ❌ Removes outdated `cd tools/repolens` commands
463
+ - ✅ Updates to `npx repolens@latest publish`
464
+ - ✅ Adds Node.js setup step if missing
465
+ - ✅ Adds environment variables (NOTION_TOKEN, REPOLENS_AI_API_KEY)
466
+ - 💾 Creates backup files for safety
467
+
468
+ **Common error it fixes:**
469
+ ```
470
+ Run cd tools/repolens
471
+ cd: tools/repolens: No such file or directory
472
+ Error: Process completed with exit code 1.
473
+ ```
474
+
475
+ See [MIGRATION.md](MIGRATION.md) for detailed upgrade guide.
476
+
477
+ ### Get Help
478
+
479
+ ```bash
480
+ npx repolens --help
481
+ npx repolens --version
482
+ ```
483
+
484
+ ---
485
+
486
+ ---
487
+
488
+ ## 📸 Example Output
489
+
490
+ ### System Map with Dependencies
491
+
492
+ ```mermaid
493
+ graph LR
494
+ CLI[bin/repolens<br/>1 file] --> Core[src/core<br/>3 files]
495
+ Publishers[src/publishers<br/>4 files] --> Core
496
+ Publishers --> Renderers[src/renderers<br/>3 files]
497
+ Publishers --> Utils[src/utils<br/>3 files]
498
+ Renderers --> Core
499
+ Delivery[src/delivery<br/>1 file] --> Publishers
500
+ Tests[tests<br/>8 files] -. tests .-> CLI
501
+ Tests -. tests .-> Core
502
+ Tests -. tests .-> Publishers
503
+
504
+ style CLI fill:#9b59b6,color:#fff
505
+ style Core fill:#f39c12,color:#000
506
+ style Publishers fill:#27ae60,color:#fff
507
+ style Renderers fill:#27ae60,color:#fff
508
+ style Delivery fill:#16a085,color:#fff
509
+ style Utils fill:#95a5a6,color:#000
510
+ style Tests fill:#e67e22,color:#fff
511
+ ```
512
+
513
+ ### System Overview (Technical Profile)
514
+
515
+ Generated from your `package.json`:
516
+
517
+ ```markdown
518
+ ## Technical Profile
519
+
520
+ **Tech Stack**: Next.js, React
521
+ **Languages**: TypeScript
522
+ **Build Tools**: Vite, Turbo
523
+ **Testing**: Vitest, Playwright
524
+ **Architecture**: Medium-sized modular structure with 42 modules
525
+ **API Coverage**: 18 API endpoints detected
526
+ **UI Pages**: 25 application pages detected
527
+ ```
528
+
529
+ ### Architecture Diff in PRs
530
+
531
+ When you open a pull request, RepoLens posts:
532
+
533
+ ```markdown
534
+ ## 📐 Architecture Diff
535
+
536
+ **Modules Changed**: 3
537
+ **New Endpoints**: 2
538
+ **Routes Modified**: 1
539
+
540
+ ### New API Endpoints
541
+ - POST /api/users/:id/verify
542
+ - GET /api/users/:id/settings
543
+
544
+ ### Modified Routes
545
+ - /dashboard → components/Dashboard.tsx (updated)
546
+ ```
547
+
548
+ ---
549
+
550
+ ## ⚙️ Configuration Reference
551
+
552
+ ### Complete Example
553
+
554
+ ```yaml
555
+ configVersion: 1 # Schema version for future migrations
556
+
557
+ project:
558
+ name: "my-awesome-app"
559
+ docs_title_prefix: "MyApp"
560
+
561
+ # Configure output destinations
562
+ publishers:
563
+ - notion
564
+ - markdown
565
+
566
+ # Notion-specific settings (optional)
567
+ notion:
568
+ branches:
569
+ - main # Only main branch publishes
570
+ - staging # Also staging
571
+ - release/* # Glob patterns supported
572
+ includeBranchInTitle: false # Clean titles without [branch-name]
573
+
574
+ # GitHub integration (optional)
575
+ github:
576
+ owner: "your-username"
577
+ repo: "your-repo-name"
578
+
579
+ # File scanning configuration
580
+ scan:
581
+ include:
582
+ - "src/**/*.{ts,tsx,js,jsx}"
583
+ - "app/**/*.{ts,tsx,js,jsx}"
584
+ - "pages/**/*.{ts,tsx,js,jsx}"
585
+ - "lib/**/*.{ts,tsx,js,jsx}"
586
+ ignore:
587
+ - "node_modules/**"
588
+ - ".next/**"
589
+ - "dist/**"
590
+ - "build/**"
591
+ - "coverage/**"
592
+
593
+ # Module organization
594
+ module_roots:
595
+ - "src"
596
+ - "app"
597
+ - "lib"
598
+ - "pages"
599
+
600
+ # Documentation pages to generate
601
+ outputs:
602
+ pages:
603
+ - key: "system_overview"
604
+ title: "System Overview"
605
+ description: "High-level snapshot and tech stack"
606
+ - key: "module_catalog"
607
+ title: "Module Catalog"
608
+ description: "Complete module inventory"
609
+ - key: "api_surface"
610
+ title: "API Surface"
611
+ description: "REST endpoints and methods"
612
+ - key: "route_map"
613
+ title: "Route Map"
614
+ description: "Frontend routes and pages"
615
+ - key: "system_map"
616
+ title: "System Map"
617
+ description: "Visual dependency graph"
618
+
619
+ # Feature flags (optional, experimental)
620
+ features:
621
+ architecture_diff: true
622
+ route_map: true
623
+ visual_diagrams: true
624
+ ```
625
+
626
+ ### Configuration Fields
627
+
628
+ | Field | Type | Required | Description |
629
+ |-------|------|----------|-------------|
630
+ | `configVersion` | number | No | Schema version (current: 1) for future migrations |
631
+ | `project.name` | string | Yes | Project name |
632
+ | `project.docs_title_prefix` | string | No | Prefix for documentation titles (default: project name) |
633
+ | `publishers` | array | Yes | Output targets: `notion`, `markdown` |
634
+ | `notion.branches` | array | No | Branch whitelist for Notion publishing. Supports globs. |
635
+ | `notion.includeBranchInTitle` | boolean | No | Add `[branch-name]` to titles (default: `true`) |
636
+ | `github.owner` | string | No | GitHub org/username for SVG hosting |
637
+ | `github.repo` | string | No | Repository name for SVG hosting |
638
+ | `scan.include` | array | Yes | Glob patterns for files to scan |
639
+ | `scan.ignore` | array | Yes | Glob patterns to exclude |
640
+ | `module_roots` | array | No | Root directories for module detection |
641
+ | `outputs.pages` | array | Yes | Documentation pages to generate |
642
+ | `features` | object | No | Experimental feature flags |
643
+
644
+ ---
645
+
646
+ ## 🔐 Environment Variables
647
+
648
+ Required for Notion publisher:
649
+
650
+ | Variable | Required | Description |
651
+ |----------|----------|-------------|
652
+ | `NOTION_TOKEN` | Yes | Integration token from notion.so/my-integrations |
653
+ | `NOTION_PARENT_PAGE_ID` | Yes | Page ID where docs will be created |
654
+ | `NOTION_VERSION` | No | API version (default: `2022-06-28`) |
655
+
656
+ **Local Development:** Create `.env` file in project root
657
+ **GitHub Actions:** Add as repository secrets in Settings → Secrets and variables → Actions
658
+
659
+ ---
660
+
661
+ ## 🏗️ Architecture & Design
662
+
663
+ ### How RepoLens Works
664
+
665
+ ```
666
+ 1. SCAN 2. ANALYZE 3. RENDER 4. PUBLISH
667
+ ──────────────────────────────────────────────────────────────────
668
+ Read files → Detect tech → Generate docs → Notion pages
669
+ from patterns stack patterns with insights + Markdown files
670
+ + SVG diagrams
671
+ ```
672
+
673
+ **Scan Phase:**
674
+ - Uses `fast-glob` to match your `scan.include` patterns
675
+ - Filters out `scan.ignore` patterns
676
+ - Reads package.json for framework/tool detection
677
+ - Analyzes file paths for Next.js routes, API endpoints
678
+
679
+ **Analyze Phase:**
680
+ - Extracts frameworks (Next.js, React, Vue, Express, etc.)
681
+ - Detects build tools (Vite, Webpack, Turbo, esbuild)
682
+ - Identifies test frameworks (Vitest, Jest, Playwright)
683
+ - Infers module relationships and dependencies
684
+
685
+ **Render Phase:**
686
+ - Groups files into modules based on `module_roots`
687
+ - Generates Mermaid diagrams showing module dependencies
688
+ - Creates technical profiles with actual stack insights
689
+ - Renders Markdown documentation
690
+
691
+ **Publish Phase:**
692
+ - Markdown: Writes files to `.repolens/` directory
693
+ - Notion: Creates/updates pages via API with retry logic
694
+ - SVG: Generates diagrams with optional mermaid-cli
695
+ - Git: Commits diagrams back to repo for GitHub CDN hosting
696
+
697
+ ### Module Dependency Detection
698
+
699
+ RepoLens infers relationships by analyzing import patterns:
700
+
701
+ ```typescript
702
+ // In src/publishers/notion.js
703
+ import { renderSystemOverview } from "../renderers/render.js";
704
+ // → Publishers depend on Renderers
705
+
706
+ // In src/renderers/render.js
707
+ import { scanRepo } from "../core/scan.js";
708
+ // → Renderers depend on Core
709
+
710
+ // Result: Dependency graph shows Publishers → Renderers → Core
711
+ ```
712
+
713
+ ---
714
+
715
+ ---
716
+
717
+ ## 🧪 Development
718
+
719
+ ### Setup
720
+
721
+ ```bash
722
+ git clone https://github.com/CHAPIBUNNY/repolens.git
723
+ cd repolens
724
+ npm install
725
+ npm link # Makes 'repolens' command available globally
726
+ ```
727
+
728
+ ### Run Tests
729
+
730
+ ```bash
731
+ npm test
732
+ ```
733
+
734
+ **Test Suite:**
735
+ - Config discovery and validation
736
+ - Branch detection (GitHub/GitLab/CircleCI)
737
+ - Markdown publisher
738
+ - Integration workflows
739
+ - Doctor command validation
740
+
741
+ **Coverage:** 32 tests passing
742
+
743
+ ### Test Package Installation Locally
744
+
745
+ Simulates the full user installation experience:
746
+
747
+ ```bash
748
+ # Pack the tarball
749
+ npm pack
750
+
751
+ # Install globally from tarball
752
+ npm install -g repolens-0.2.0.tgz
753
+
754
+ # Verify
755
+ repolens --version
756
+ ```
757
+
758
+ ### Project Structure
759
+
760
+ ```
761
+ repolens/
762
+ ├── bin/
763
+ │ └── repolens.js # CLI executable wrapper
764
+ ├── src/
765
+ │ ├── cli.js # Command orchestration + banner
766
+ │ ├── init.js # Scaffolding command
767
+ │ ├── doctor.js # Validation command
768
+ │ ├── core/
769
+ │ │ ├── config.js # Config loading + validation
770
+ │ │ ├── config-schema.js # Schema version tracking
771
+ │ │ ├── diff.js # Git diff operations
772
+ │ │ └── scan.js # Repository scanning + metadata extraction
773
+ │ ├── renderers/
774
+ │ │ ├── render.js # System overview, catalog, API, routes
775
+ │ │ ├── renderDiff.js # Architecture diff rendering
776
+ │ │ └── renderMap.js # Mermaid dependency graphs
777
+ │ ├── publishers/
778
+ │ │ ├── index.js # Publisher orchestration + branch filtering
779
+ │ │ ├── publish.js # Notion publishing pipeline
780
+ │ │ ├── notion.js # Notion API integration
781
+ │ │ └── markdown.js # Local Markdown generation
782
+ │ ├── delivery/
783
+ │ │ └── comment.js # PR comment delivery
784
+ │ └── utils/
785
+ │ ├── logger.js # Logging utilities
786
+ │ ├── retry.js # API retry logic
787
+ │ ├── branch.js # Branch detection (multi-platform)
788
+ │ └── mermaid.js # SVG rendering + GitHub URL handling
789
+ ├── tests/ # Vitest test suite
790
+ ├── .repolens.yml # Dogfooding config
791
+ ├── package.json
792
+ ├── CHANGELOG.md
793
+ ├── RELEASE.md
794
+ └── ROADMAP.md
795
+ ```
796
+
797
+ ---
798
+
799
+ ## 🚀 Release Process
800
+
801
+ RepoLens uses automated GitHub Actions releases.
802
+
803
+ ### Creating a Release
804
+
805
+ ```bash
806
+ # Patch version (0.2.0 → 0.2.1) - Bug fixes
807
+ npm run release:patch
808
+
809
+ # Minor version (0.2.0 → 0.3.0) - New features
810
+ npm run release:minor
811
+
812
+ # Major version (0.2.0 → 1.0.0) - Breaking changes
813
+ npm run release:major
814
+
815
+ # Push the tag to trigger workflow
816
+ git push --follow-tags
817
+ ```
818
+
819
+ **What happens:**
820
+ 1. ✅ All tests run
821
+ 2. ✅ Package tarball created
822
+ 3. ✅ GitHub Release published
823
+ 4. ✅ Tarball attached as artifact
824
+
825
+ See [RELEASE.md](./RELEASE.md) for detailed workflow.
826
+
827
+ ---
828
+
829
+ ## 🤝 Contributing
830
+
831
+ RepoLens is currently in early access. v1.0 will open for community contributions.
832
+
833
+ **Ways to help:**
834
+ - **Try it out**: Install and use in your projects
835
+ - **Report issues**: Share bugs, edge cases, or UX friction
836
+ - **Request features**: Tell us what's missing
837
+ - **Share feedback**: What works? What doesn't?
838
+
839
+ ---
840
+
841
+ ## 🗺️ Roadmap to v1.0
842
+
843
+ **Current Status:** v0.2.0 — ~92% production-ready
844
+
845
+ ### Completed ✅
846
+
847
+ - [x] CLI commands: `init`, `doctor`, `publish`, `version`, `help`
848
+ - [x] Config schema v1 with validation
849
+ - [x] Auto-discovery of `.repolens.yml`
850
+ - [x] Publishers: Notion + Markdown
851
+ - [x] Branch-aware publishing with filtering
852
+ - [x] Smart tech stack detection from package.json
853
+ - [x] Dependency graphs with actual module relationships
854
+ - [x] Visual diagrams with optional SVG rendering
855
+ - [x] GitHub Actions automation
856
+ - [x] PR architecture diff comments
857
+ - [x] Performance guardrails (10k warning, 50k limit)
858
+ - [x] Comprehensive test suite (32 tests)
859
+ - [x] Interactive mermaid-cli installation
860
+
861
+ ### In Progress 🚧
862
+
863
+ - [ ] Production stability validation
864
+ - [ ] Enhanced error messages and debugging
865
+ - [ ] Performance optimization for large repos
866
+ - [ ] Additional framework detection (Remix, SvelteKit, Astro)
867
+
868
+ ### Planned for v1.0 🎯
869
+
870
+ - [ ] Plugin system for custom renderers
871
+ - [ ] GraphQL schema detection
872
+ - [ ] TypeScript type graph analysis
873
+ - [ ] Interactive configuration wizard
874
+ - [ ] Watch mode for local development
875
+ - [ ] npm registry publication
876
+
877
+ See [ROADMAP.md](./ROADMAP.md) for detailed planning.
878
+
879
+ ---
880
+
881
+ ## 📄 License
882
+
883
+ MIT
884
+
885
+ ---
886
+
887
+ ## 💬 Support & Contact
888
+
889
+ - **Issues**: [GitHub Issues](https://github.com/CHAPIBUNNY/repolens/issues)
890
+ - **Discussions**: [GitHub Discussions](https://github.com/CHAPIBUNNY/repolens/discussions)
891
+ - **Email**: Contact repository maintainers
892
+
893
+ ---
894
+
895
+ <div align="center">
896
+
897
+ **Made with 🔍 for developers who care about architecture**
898
+
899
+ </div>