Skip to content

Commit 1f090fc

Browse files
committed
summariser v2
1 parent 5d71e6b commit 1f090fc

File tree

249 files changed

+19689
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+19689
-14
lines changed

README.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Codebase Summary Bot
2+
3+
Production-grade codebase summarizer for AI-powered code review, agent pipelines, onboarding, and repository intelligence.
4+
5+
> Optimized for LLMs, AI agents, and automated code reviewers
6+
> Fully modular architecture, SaaS-ready, CI/CD friendly
7+
> Supports JavaScript, TypeScript, monorepos, and modern stacks
8+
9+
---
10+
11+
## Features
12+
13+
* Framework detection (frontend + backend)
14+
* Business vs Utility service classification
15+
* API route extraction (public vs internal)
16+
* Database models & schemas extraction
17+
* Utility function extraction + domain classification
18+
* Global pattern detection (ORMs, auth, validation, state management, logging, etc)
19+
* Git metadata capture (SHA, branch, remote)
20+
* Fully pluggable as GitHub Action or SaaS microservice
21+
* LLM-optimized output for AI reviewers
22+
23+
---
24+
25+
## Installation
26+
27+
```bash
28+
npm install -g codebase-summary-bot
29+
```
30+
31+
Or clone the repo directly:
32+
33+
```bash
34+
git clone https://github.com/YOUR-ORG/codebase-summary-bot.git
35+
cd codebase-summary-bot
36+
npm install
37+
```
38+
39+
---
40+
41+
## Usage
42+
43+
From your project root directory:
44+
45+
```bash
46+
codebase-summary-bot
47+
```
48+
49+
### CLI Options:
50+
51+
| Option | Description | Default |
52+
| ---------- | ---------------------- | ----------------------- |
53+
| `--output` | Output file path | `codebase-summary.json` |
54+
| `--limit` | Max items per category | `100` |
55+
56+
Example:
57+
58+
```bash
59+
codebase-summary-bot --output=./summary.json --limit=50
60+
```
61+
62+
---
63+
64+
## Output Structure
65+
66+
The bot generates a fully LLM-ready JSON summary:
67+
68+
```json
69+
{
70+
"schemaVersion": "3.0.0",
71+
"generatedAt": "...",
72+
"git": {
73+
"sha": "...",
74+
"branch": "...",
75+
"remote": "..."
76+
},
77+
"modules": [...],
78+
"services": {
79+
"businessServices": [...],
80+
"utilityServices": [...]
81+
},
82+
"apiRoutes": {
83+
"publicRoutes": [...],
84+
"internalRoutes": [...]
85+
},
86+
"dbModels": [...],
87+
"utils": {
88+
"byDomain": {...},
89+
"files": [...]
90+
},
91+
"frameworks": {
92+
"frontend": "...",
93+
"backend": "..."
94+
},
95+
"globalPatterns": [...]
96+
}
97+
```
98+
99+
---
100+
101+
## Use Cases
102+
103+
* Feed into AI code reviewers
104+
* Boost LLM agents with repository context
105+
* Automated pull request quality gates
106+
* Onboarding docs for new engineers
107+
* SaaS pipeline integrations
108+
109+
---
110+
111+
## GitHub Action (Coming soon)
112+
113+
You can embed Codebase Summary Bot into your CI:
114+
115+
```yaml
116+
name: Codebase Summary
117+
118+
on:
119+
push:
120+
branches:
121+
- main
122+
123+
jobs:
124+
summarize:
125+
runs-on: ubuntu-latest
126+
steps:
127+
- uses: actions/checkout@v3
128+
- uses: your-org/codebase-summary-bot@v3
129+
```
130+
131+
---
132+
133+
## Technology Stack
134+
135+
* Node.js (async / promise-based)
136+
* Fast-glob (fast concurrent filesystem traversal)
137+
* Modular extractor architecture
138+
* SaaS extensible design
139+
140+
---
141+
142+
## License
143+
144+
MIT License — Fully open-source for personal & commercial use.
145+
146+
---
147+
148+
## Credits
149+
150+
Built and designed for modern AI-native development pipelines.

action.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
name: 'Codebase Summarizer'
2-
description: 'Generate a production-grade codebase summary for AI code reviews'
3-
author: 'Your Name'
1+
name: 'Codebase Summary Bot'
2+
description: 'LLM-optimized codebase summarizer for AI code review pipelines, agents, and onboarding.'
3+
author: 'Libin V Babu <www.libin.in>'
44
branding:
5-
icon: 'file-text'
5+
icon: 'code'
66
color: 'blue'
7+
78
inputs:
8-
output-file:
9-
description: 'Output file path'
9+
output:
10+
description: 'Output file path for the codebase summary JSON'
1011
required: false
11-
default: 'code-review-summary.json'
12+
default: 'codebase-summary.json'
13+
limit:
14+
description: 'Max items per category (default: 100)'
15+
required: false
16+
default: '100'
17+
1218
runs:
1319
using: 'node20'
14-
main: 'generate-codebase-summary.js'
20+
main: 'index.js'

codebase-summary.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"schemaVersion": "3.0.0",
3+
"generatedAt": "2025-06-13T07:29:02.905Z",
4+
"git": {
5+
"sha": null,
6+
"branch": null,
7+
"remote": null
8+
},
9+
"modules": [],
10+
"services": {
11+
"businessServices": [],
12+
"utilityServices": [
13+
"UtilityAnalyzer"
14+
]
15+
},
16+
"apiRoutes": {
17+
"publicRoutes": [],
18+
"internalRoutes": []
19+
},
20+
"dbModels": [],
21+
"utils": {
22+
"byDomain": {
23+
"Date/Time": [
24+
{
25+
"file": "utilityAnalyzer.js",
26+
"functions": [
27+
"assignments"
28+
]
29+
}
30+
]
31+
},
32+
"files": [
33+
{
34+
"name": "utilityAnalyzer.js",
35+
"domain": "Date/Time",
36+
"functions": [
37+
"assignments"
38+
]
39+
}
40+
]
41+
},
42+
"frameworks": {
43+
"backend": "Node.js",
44+
"frontend": "None detected",
45+
"dependencies": {
46+
"fast-glob": "^3.3.1",
47+
"minimist": "^1.2.8"
48+
}
49+
},
50+
"globalPatterns": [
51+
"Async/Await Pattern",
52+
"Dependency Injection",
53+
"Middleware Pattern",
54+
"React Hooks",
55+
"TypeScript Interfaces"
56+
]
57+
}

config.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
export const DEFAULT_LIMIT = 100;
2+
3+
export const IGNORED_PATHS = [
4+
'**/node_modules/**',
5+
'**/dist/**',
6+
'**/build/**',
7+
'**/coverage/**',
8+
'**/out/**',
9+
'**/test*/**',
10+
'**/__tests__/**',
11+
'**/tmp/**',
12+
'**/.next/**',
13+
'**/.git/**',
14+
'**/logs/**',
15+
'**/.idea/**'
16+
];
17+
18+
export const MODULE_PATTERNS = [
19+
'src/modules/*',
20+
'src/*',
21+
'packages/*',
22+
'apps/*'
23+
];
24+
25+
export const SERVICE_PATTERNS = [
26+
'**/*Service.{js,ts}',
27+
'**/services/**/*.{js,ts}',
28+
'**/*Util.{js,ts}',
29+
'**/*Helper.{js,ts}',
30+
'**/*utils*.{js,ts}',
31+
'**/*helper*.{js,ts}',
32+
'**/*util*.{js,ts}'
33+
];
34+
35+
export const ROUTE_PATTERNS = [
36+
'**/routes/**/*.{js,ts}',
37+
'**/controllers/**/*.{js,ts}',
38+
'**/api/**/*.{js,ts}',
39+
'**/*router*.{js,ts}',
40+
'**/*route*.{js,ts}'
41+
];
42+
43+
export const MODEL_PATTERNS = [
44+
'**/models/**/*.{js,ts}',
45+
'**/schemas/**/*.{js,ts}',
46+
'**/entities/**/*.{js,ts}',
47+
'**/*Model.{js,ts}',
48+
'**/*Schema.{js,ts}'
49+
];
50+
51+
export const UTIL_PATTERNS = [
52+
'**/utils/**/*.{js,ts}',
53+
'**/helpers/**/*.{js,ts}',
54+
'**/lib/**/*.{js,ts}',
55+
'**/*util*.{js,ts}',
56+
'**/*helper*.{js,ts}'
57+
];
58+
59+
export const SOURCE_PATTERNS = [
60+
'src/**/*.{js,ts}',
61+
'**/*.{js,ts}'
62+
];

index.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env node
2+
3+
import { Summarizer } from './src/summarizer.js';
4+
import minimist from 'minimist';
5+
import fs from 'fs/promises';
6+
import path from 'path';
7+
import packageData from './package.json' assert { type: 'json' };
8+
const { version } = packageData;
9+
10+
11+
async function run() {
12+
console.log(`🚀 Codebase Summary Bot v${version}\n==============================`);
13+
14+
const args = minimist(process.argv.slice(2));
15+
const projectRoot = process.cwd();
16+
17+
const outputFile = args.output || 'codebase-summary.json';
18+
const limit = parseInt(args.limit || '100');
19+
20+
try {
21+
const summarizer = new Summarizer({
22+
projectRoot,
23+
outputFile,
24+
limit
25+
});
26+
27+
const summary = await summarizer.analyze();
28+
29+
await fs.writeFile(
30+
path.join(projectRoot, outputFile),
31+
JSON.stringify(summary, null, 2),
32+
'utf8'
33+
);
34+
35+
console.log(`✅ Summary written to ${outputFile}`);
36+
} catch (err) {
37+
console.error('💥 Summary failed:', err);
38+
process.exit(1);
39+
}
40+
}
41+
42+
run();

0 commit comments

Comments
 (0)