codeflow-hook 2.0.0 → 2.1.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/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # Codeflow Commander — Nexus Gateway CLI
1
+ # Codeflow Hook
2
2
 
3
3
  **AI-Powered Code Analysis and Git Hook Management**
4
4
 
5
- A lightweight command-line tool that provides AI-driven code analysis, automated git hook installation, and intelligent code review capabilities. This CLI client analyzes your local code changes using advanced AI models and helps maintain code quality through automated pre-commit and pre-push checks.
5
+ A lightweight command-line tool that provides AI-driven code analysis, automated git hook installation, and intelligent code review capabilities. This standalone CLI tool analyzes your local code changes using advanced AI models (Gemini, OpenAI GPT, or Claude) and helps maintain code quality through automated pre-commit and pre-push checks.
6
6
 
7
- **⚠️ Important**: This is the **client-side CLI tool** only. Enterprise features like the Enterprise Knowledge Graph (EKG), Autonomous Agent Network (AAN), and ingestion services are part of the broader Codeflow Commander platform and require separate enterprise deployment.
7
+ **✨ Standalone Package**: This CLI tool works independently and can be installed globally via npm. No additional setup or enterprise infrastructure required.
8
8
 
9
- ## 🚀 What This CLI Tool Provides
9
+ ## 🚀 Features
10
10
 
11
11
  ### **AI-Powered Code Analysis**
12
12
  - **Local Code Diff Analysis**: Analyze git diffs using Gemini, OpenAI GPT, or Claude AI models
@@ -32,18 +32,6 @@ A lightweight command-line tool that provides AI-driven code analysis, automated
32
32
  - **Anthropic Claude**: Integration with Claude 3 Opus, Sonnet, and Haiku
33
33
  - **Custom Endpoints**: Connect to self-hosted or custom AI model endpoints
34
34
 
35
- ## 📦 How It Works
36
-
37
- The CLI tool operates entirely on your local machine and analyzes your code changes using AI. Here's the workflow:
38
-
39
- 1. **Local Analysis**: When you run analysis, the tool captures your git diff locally
40
- 2. **AI Processing**: Sends the diff to your configured AI provider (Gemini/OpenAI/Claude)
41
- 3. **Context Enhancement**: Optionally includes your project's indexed knowledge for better analysis
42
- 4. **Feedback Generation**: Returns quality scores, issues, and recommendations
43
- 5. **Hook Integration**: Automatically runs during git operations to maintain code quality
44
-
45
- **No data is sent to external servers** except for AI API calls to your configured provider. Your code stays on your machine.
46
-
47
35
  ## 📦 Installation
48
36
 
49
37
  ### Global Installation
@@ -58,197 +46,69 @@ npm install -g codeflow-hook
58
46
  npm install --save-dev codeflow-hook
59
47
  ```
60
48
 
61
- ## ⚙️ Setup
49
+ ## ⚙️ Quick Start
62
50
 
63
51
  ### 1. Configure AI Provider
64
52
 
65
53
  Choose your AI provider and configure with your API key:
66
54
 
67
- **Gemini (default):**
68
55
  ```bash
56
+ # Gemini (default, recommended)
69
57
  codeflow-hook config -p gemini -k YOUR_GEMINI_API_KEY
70
- ```
71
- *You'll be prompted to select a model: `gemini-1.5-pro-latest`, `gemini-1.5-flash-latest`, or `gemini-pro`*
72
58
 
73
- **OpenAI:**
74
- ```bash
59
+ # OpenAI
75
60
  codeflow-hook config -p openai -k YOUR_OPENAI_API_KEY
76
- ```
77
- *You'll be prompted to select a model: `gpt-4o`, `gpt-4-turbo`, `gpt-4`, or `gpt-3.5-turbo`*
78
61
 
79
- **Claude/Anthropic:**
80
- ```bash
62
+ # Claude/Anthropic
81
63
  codeflow-hook config -p claude -k YOUR_CLAUDE_API_KEY
82
64
  ```
83
- *You'll be prompted to select a model: `claude-3-opus-20240229`, `claude-3-sonnet-20240229`, or `claude-3-haiku-20240307`*
84
-
85
- **Custom model/URL:**
86
- ```bash
87
- codeflow-hook config -p openai -k YOUR_API_KEY -m gpt-3.5-turbo -u https://your-custom-endpoint.com
88
- ```
89
65
 
90
66
  ### 2. Install Git Hooks
91
67
 
92
- In your project directory:
93
-
94
68
  ```bash
95
69
  codeflow-hook install
96
70
  ```
97
71
 
98
- This creates:
99
- - `pre-commit`: AI analysis of staged changes
100
- - `pre-push`: Full CI/CD simulation (tests + AI review)
101
-
102
- ### 3. Index Project Knowledge (RAG Setup)
103
-
104
- Build a local knowledge base for context-aware analysis:
72
+ ### 3. Start Analyzing Code
105
73
 
106
74
  ```bash
107
- # Index current project files for RAG
108
- codeflow-hook index
109
-
110
- # Dry run to see what files would be indexed
111
- codeflow-hook index --dry-run
112
- ```
113
-
114
- The knowledge base is stored in `.codeflow/index/` and includes:
115
- - README.md and documentation files
116
- - Source code files (.ts, .tsx, .js, .jsx, .json)
117
- - Configuration files (package.json, jest.config.*, etc.)
118
- - Architecture and design documents
119
-
120
- ### 4. Check Status
75
+ # Analyze your current changes
76
+ git diff | codeflow-hook analyze-diff
121
77
 
122
- ```bash
123
- codeflow-hook status
78
+ # Or let the hooks run automatically on commit/push
79
+ git add .
80
+ git commit -m "feat: add new feature"
124
81
  ```
125
82
 
126
83
  ## 🛠️ Commands
127
84
 
128
85
  ### Core Commands
129
86
 
130
- **Index Project Knowledge**:
131
87
  ```bash
132
- # Build local RAG knowledge base
133
- codeflow-hook index
134
-
135
- # Preview what will be indexed
136
- codeflow-hook index --dry-run
88
+ codeflow-hook config # Configure AI provider settings
89
+ codeflow-hook install # Install git hooks
90
+ codeflow-hook analyze-diff # Analyze code changes
91
+ codeflow-hook index # Build local knowledge base
92
+ codeflow-hook status # Check installation status
137
93
  ```
138
94
 
139
- **Analyze Diff**:
140
- ```bash
141
- # Analyze staged changes
142
- git diff --staged | codeflow-hook analyze-diff
143
-
144
- # Disable RAG context (faster but less precise)
145
- git diff | codeflow-hook analyze-diff --no-rag
95
+ ### Usage Examples
146
96
 
147
- # Use legacy monolithic analysis
148
- git diff | codeflow-hook analyze-diff --legacy
149
- ```
150
-
151
- **Configuration & Setup**:
152
97
  ```bash
153
- # Configure AI provider
154
- codeflow-hook config -p gemini -k YOUR_API_KEY
98
+ # Configure with Gemini (default)
99
+ codeflow-hook config -p gemini -k your-api-key
155
100
 
156
- # Install git hooks
101
+ # Install hooks in current project
157
102
  codeflow-hook install
158
103
 
159
- # Check installation status
160
- codeflow-hook status
161
- ```
162
-
163
- ### Advanced Options
164
-
165
- ```bash
166
- # Use legacy mode for backwards compatibility
167
- codeflow-hook analyze-diff --legacy
168
-
169
- # Skip RAG for faster analysis
170
- codeflow-hook analyze-diff --no-rag
171
-
172
- # Custom hooks directory
173
- codeflow-hook install --hooks-dir .custom-hooks
174
- ```
175
-
176
- ### View Help
177
-
178
- ```bash
179
- codeflow-hook --help # Main help
180
- codeflow-hook index --help # Index command help
181
- codeflow-hook analyze-diff --help # Analysis options
182
- ```
183
-
184
- ## 🔄 How It Works
185
-
186
- ### Pre-commit Hook
187
- - Analyzes staged changes only
188
- - Provides quick feedback on code quality
189
- - Prevents problematic commits
190
-
191
- ### Pre-push Hook
192
- - Runs full test suite
193
- - Performs comprehensive AI code review
194
- - Simulates deployment pipeline
195
- - Blocks pushes with failing checks
196
-
197
- ### AI Analysis Features
198
- - Code quality assessment
199
- - Security vulnerability detection
200
- - Performance optimization suggestions
201
- - Best practice recommendations
202
- - Maintainability evaluation
203
-
204
- ## 💡 Usage Examples
205
-
206
- ### Standard Development Workflow
207
-
208
- ```bash
209
- # Stage your changes
210
- git add .
211
-
212
- # Pre-commit hook automatically runs AI analysis
213
- git commit -m "feat: add new authentication"
214
-
215
- # Pre-push hook runs tests and full AI review
216
- git push origin main
217
- ```
218
-
219
- ### Manual Analysis
220
-
221
- ```bash
222
- # Analyze uncommitted changes
223
- git diff | codeflow-hook analyze-diff
224
-
225
- # Analyze specific files
226
- git diff path/to/file.js | codeflow-hook analyze-diff
227
-
228
- # Analyze between commits
229
- git diff HEAD~1 HEAD | codeflow-hook analyze-diff
230
- ```
231
-
232
- ## 🎯 AI Analysis Output
233
-
234
- The tool provides:
235
-
236
- - **Rating**: 1-10 quality score with color coding
237
- - **Summary**: Brief assessment of changes
238
- - **Issues**: Specific problems with solutions
239
- - **Recommendations**: Improvement suggestions
240
-
241
- Example output:
242
- ```
243
- ⭐ **Rating:** 9/10
244
- 📝 **Summary:** Clean implementation with good separation of concerns
104
+ # Analyze staged changes
105
+ git diff --staged | codeflow-hook analyze-diff
245
106
 
246
- ⚠️ **Issues:**
247
- - Consider adding input validation for edge cases
107
+ # Build project knowledge base
108
+ codeflow-hook index
248
109
 
249
- 💡 **Recommendations:**
250
- - Add comprehensive error handling
251
- - Consider extracting common logic to a utility function
110
+ # Check everything is working
111
+ codeflow-hook status
252
112
  ```
253
113
 
254
114
  ## 🔧 Configuration
@@ -259,31 +119,28 @@ Configuration is stored in `~/.codeflow-hook/config.json`:
259
119
  {
260
120
  "provider": "gemini",
261
121
  "apiKey": "your-api-key",
262
- "apiUrl": "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent",
263
- "model": "gemini-pro"
122
+ "model": "gemini-1.5-pro-latest"
264
123
  }
265
124
  ```
266
125
 
267
126
  ### Supported AI Providers
268
127
 
269
- - **Gemini**: `provider: "gemini"` - Default, uses Google AI
128
+ - **Gemini**: `provider: "gemini"` - Google AI (recommended)
270
129
  - **OpenAI**: `provider: "openai"` - GPT models
271
130
  - **Claude**: `provider: "claude"` - Anthropic models
272
131
 
273
- Each provider has optimized prompts and supports custom endpoints.
274
-
275
132
  ## 📋 Requirements
276
133
 
277
134
  - Node.js 16+
278
135
  - Git repository
279
- - Gemini API key
136
+ - AI API key (Gemini, OpenAI, or Claude)
280
137
 
281
- ## Security
138
+ ## 🔒 Security & Privacy
282
139
 
283
- - API keys stored locally (not in your repo)
284
- - Have to make an .env file for the credentials
285
- - No data sent to third parties except Google Gemini
286
- - Code diffs analyzed locally before sending
140
+ - **Local Processing**: All code analysis happens on your machine
141
+ - **API Keys Stored Locally**: Keys are stored in `~/.codeflow-hook/config.json`
142
+ - **No Data Collection**: Code diffs are only sent to your configured AI provider
143
+ - **No Telemetry**: No usage data is collected or transmitted
287
144
 
288
145
  ## 🐛 Troubleshooting
289
146
 
@@ -296,241 +153,47 @@ codeflow-hook config -k YOUR_API_KEY
296
153
 
297
154
  **Hooks not running**
298
155
  ```bash
299
- - **Design Pattern Compliance**: Validation against organizational architectural standards
300
- - **Coupling Analysis**: Detection of tight coupling and circular dependencies
301
- - **Layer Architecture**: Enforcement of proper separation between presentation, business logic, and data layers
302
- - **Complexity Assessment**: Monitoring of code complexity and maintainability metrics
303
-
304
- **⚡ Performance Agent**:
305
- - **Algorithm Analysis**: Detection of inefficient algorithms and time/space complexity issues
306
- - **Memory Optimization**: Identification of memory leaks and inefficient data structures
307
- - **I/O Optimization**: Analysis of database queries, file operations, and network calls
308
- - **Caching Opportunities**: Recommendations for implementing caching strategies
309
-
310
- **✨ Quality Agent**:
311
- - **Code Style Enforcement**: Automated linting and formatting consistency checks
312
- - **Documentation Analysis**: Validation of code comments, JSDoc, and README completeness
313
- - **Test Coverage Assessment**: Analysis of unit test coverage and quality
314
- - **Dead Code Detection**: Identification of unused functions, variables, and imports
315
-
316
- ### **Federated Data Architecture**
317
- Enterprise-scale data management across distributed repositories:
318
-
319
- **🌐 Enterprise Knowledge Graph (EKG)**:
320
- - Multi-modal data integration (code, documentation, metrics, design artifacts)
321
- - Semantic relationship mapping across the entire organization
322
- - Real-time knowledge updates with conflict-free replication
323
-
324
- **📈 Predictive Intelligence Engine (PIE)**:
325
- - Time-series analytics for development velocity and quality trends
326
- - Anomaly detection using unsupervised learning algorithms
327
- - Forecasting models trained on enterprise development data
328
-
329
- ### **Distributed Execution Framework**
330
- Coordination of autonomous operations across multiple systems:
331
-
332
- **⚡ Distributed Execution Engine (DEE)**:
333
- - Multi-repository workflow orchestration with dependency management
334
- - Resource optimization through intelligent load balancing
335
- - Federated state management with eventual consistency guarantees
336
-
337
- **🔐 Governance Safety Framework (GSF)**:
338
- - Risk-based permission evaluation with dynamic access controls
339
- - Multi-level audit trails with blockchain-verified immutability
340
- - Emergency stop mechanisms with graduated escalation protocols
341
-
342
- ### **Structured Intelligence Output Format**
343
- Enterprise reporting with actionable insights and automated workflows:
344
-
345
- ```
346
- 🏢 Enterprise Code Review Summary:
347
- 🔒 Organization-wide Security risks: 2
348
- 🏗️ Architecture Optimization opportunities: 7
349
- 📝 Cross-repository Maintainability issues: 15
350
- 🎯 Predictive Maintenance alerts: 3
351
-
352
- 📊 Trend Analysis:
353
- 📈 Code quality velocity: +12% (improving)
354
- 📉 Tech debt accumulation: -8% (reducing)
355
- 🎲 Risk exposure index: LOW (confidence: 94%)
356
-
357
- 📋 Recommended Actions:
358
- 🔧 Automated fixes available for 23 issues
359
- 🚀 Cross-repository refactor suggested for auth module
360
- 📅 Maintenance window scheduled for Q4 dependency updates
361
- ```
362
-
363
- ### **Multi-Repository Analysis Benefits**
364
- - **Scale**: Analyzes thousands of repositories simultaneously
365
- - **Intelligence**: Learns organizational patterns and standards
366
- - **Automation**: Initiates cross-cutting improvements autonomously
367
- - **Governance**: Ensures compliance across all engineering activities
368
- - **Prediction**: Forecasts development bottlenecks before they occur
369
-
370
- ## 💡 Usage Examples
371
-
372
- ### Standard Development Workflow
373
-
374
- ```bash
375
- # Stage your changes
376
- git add .
377
-
378
- # Pre-commit hook automatically runs AI analysis
379
- git commit -m "feat: add new authentication"
380
-
381
- # Pre-push hook runs tests and full AI review
382
- git push origin main
383
- ```
384
-
385
- ### Manual Analysis
386
-
387
- ```bash
388
- # Analyze uncommitted changes
389
- git diff | codeflow-hook analyze-diff
390
-
391
- # Analyze specific files
392
- git diff path/to/file.js | codeflow-hook analyze-diff
393
-
394
- # Analyze between commits
395
- git diff HEAD~1 HEAD | codeflow-hook analyze-diff
396
- ```
397
-
398
- ## 🎯 AI Analysis Output
399
-
400
- The tool provides:
401
-
402
- - **Rating**: 1-10 quality score with color coding
403
- - **Summary**: Brief assessment of changes
404
- - **Issues**: Specific problems with solutions
405
- - **Recommendations**: Improvement suggestions
406
-
407
- Example output:
408
- ```
409
- ⭐ **Rating:** 9/10
410
- 📝 **Summary:** Clean implementation with good separation of concerns
411
-
412
- ⚠️ **Issues:**
413
- - Consider adding input validation for edge cases
414
-
415
- 💡 **Recommendations:**
416
- - Add comprehensive error handling
417
- - Consider extracting common logic to a utility function
418
- ```
419
-
420
- ## 🔧 Configuration
421
-
422
- Configuration is stored in `~/.codeflow-hook/config.json`:
423
-
424
- ```json
425
- {
426
- "provider": "gemini",
427
- "apiKey": "your-api-key",
428
- "apiUrl": "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent",
429
- "model": "gemini-pro"
430
- }
156
+ codeflow-hook install
157
+ # On Windows, ensure hooks are executable
431
158
  ```
432
159
 
433
- ### Supported AI Providers
434
-
435
- - **Gemini**: `provider: "gemini"` - Default, uses Google AI
436
- - **OpenAI**: `provider: "openai"` - GPT models
437
- - **Claude**: `provider: "claude"` - Anthropic models
438
-
439
- Each provider has optimized prompts and supports custom endpoints.
440
-
441
- ## 📋 Requirements
442
-
443
- - Node.js 16+
444
- - Git repository
445
- - Gemini API key
446
-
447
- ## 🔒 Security
448
-
449
- - API keys stored locally (not in your repo)
450
- - Have to make an .env file for the credentials
451
- - No data sent to third parties except Google Gemini
452
- - Code diffs analyzed locally before sending
160
+ **API errors**
161
+ - Verify your API key is valid and has quota remaining
162
+ - Check your internet connection
163
+ - Try a different AI provider
453
164
 
454
- ## 🐛 Troubleshooting
165
+ ### Manual Hook Setup
455
166
 
456
- ### Common Issues
167
+ If automatic installation fails:
457
168
 
458
- **"No configuration found"**
169
+ 1. Create `.git/hooks/pre-commit`:
459
170
  ```bash
460
- codeflow-hook config -k YOUR_API_KEY
171
+ #!/bin/sh
172
+ codeflow-hook analyze-diff
461
173
  ```
462
174
 
463
- **Hooks not running**
175
+ 2. Make it executable:
464
176
  ```bash
465
- codeflow-hook install
466
- # Ensure scripts are executable
467
- chmod +x .git/hooks/pre-commit .git/hooks/pre-push
177
+ chmod +x .git/hooks/pre-commit
468
178
  ```
469
179
 
470
- **API errors**
471
- - Verify your API key is valid
472
- - Check Gemini API service status
473
- - Ensure you have quota remaining
474
-
475
- ### Manual Hook Setup
476
-
477
- If automatic installation fails:
180
+ ## 📄 License
478
181
 
479
- 1. Create `.git/hooks/pre-commit`
480
- 2. Add executable permissions: `chmod +x .git/hooks/pre-commit`
481
- 3. Call the CLI: `npx codeflow-hook analyze-diff "$(git diff --cached)"`
182
+ MIT License
482
183
 
483
184
  ## 🤝 Contributing
484
185
 
485
186
  1. Fork the repository
486
187
  2. Create a feature branch
487
188
  3. Make your changes
488
- 4. Run tests: `npm test`
189
+ 4. Test thoroughly
489
190
  5. Submit a pull request
490
191
 
491
- ## 📄 License
492
-
493
- MIT License - see LICENSE file for details
494
-
495
- ## 🎉 Acknowledgments
496
-
497
- Built with ❤️ using enterprise-grade technologies:
498
-
499
- ### **Core Intelligence Stack**
500
- - **Multi-Modal AI Integration**: Google Gemini, OpenAI GPT-4, Anthropic Claude
501
- - **Distributed Graph Database**: Amazon Neptune for Enterprise Knowledge Graph operations
502
- - **Ingestion & Query Services**: Microservices architecture with GraphQL APIs
503
- - **Autonomous Agent Network**: Specialized agents for Security, Architecture, Performance, and Quality analysis
504
- - **Federated Learning Infrastructure**: PyTorch and TensorFlow for ML model training
505
- - **Container Orchestration**: Kubernetes for enterprise-scale deployment
506
-
507
- ### **Development & CLI Framework**
508
- - **Commander.js**: Professional CLI experience and command orchestration
509
- - **Chalk & Ora**: Advanced terminal rendering with progress indicators
510
- - **Axios**: Enterprise HTTP client with retry logic and circuit breakers
511
- - **Node.js & TypeScript**: Type-safe, scalable runtime environment
512
-
513
- ### **Enterprise Integrations**
514
- - **Git Platforms**: Native GitHub, GitLab, and Bitbucket integration
515
- - **Project Management**: JIRA, Linear, and Azure DevOps workflows
516
- - **Communication**: Slack, Microsoft Teams, and Discord integrations
517
- - **Monitoring**: Datadog, New Relic, and Prometheus telemetry
518
-
519
- ### **Security & Governance**
520
- - **Audit Framework**: Blockchain-verified audit trails
521
- - **Access Management**: OAuth 2.0, SAML, and LDAP integration
522
- - **Encryption**: End-to-end encryption with key management
523
- - **Compliance**: SOC 2, GDPR, and enterprise security standards
524
-
525
192
  ---
526
193
 
527
- **🚀 Ready to transform your organization's engineering capabilities?**
528
-
529
- Join the autonomous engineering revolution with Codeflow Commander Nexus Gateway — where AI meets enterprise-scale software development.
194
+ **🚀 Enhance your development workflow with AI-powered code analysis!**
530
195
 
531
- **Install today and experience organization-wide autonomous engineering:**
532
196
  ```bash
533
197
  npm install -g codeflow-hook
534
- ```
535
-
536
- **Visit [codeflow-commander-nexus-gateway](https://github.com/Sharv619/codeflow-commander---nexus-gateway) to explore the full platform.**
198
+ codeflow-hook config -k YOUR_API_KEY
199
+ codeflow-hook install
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { Command } from 'commander';
4
4
  import chalk from 'chalk';
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
+
1
2
  {
2
3
  "name": "codeflow-hook",
3
- "version": "2.0.0",
4
+ "version": "2.1.0",
4
5
  "description": "An interactive CI/CD simulator and lightweight pre-push code reviewer using Gemini AI",
5
6
  "type": "module",
6
7
  "main": "index.js",
@@ -14,7 +15,7 @@
14
15
  ],
15
16
  "scripts": {
16
17
  "build": "tsc",
17
- "test": "echo \"Error: no test specified\" && exit 1"
18
+ "test": "jest"
18
19
  },
19
20
  "keywords": [
20
21
  "git",
@@ -38,7 +39,8 @@
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/node": "^18.0.0",
41
- "typescript": "^5.0.0"
42
+ "typescript": "^5.0.0",
43
+ "jest": "^29.7.0"
42
44
  },
43
45
  "engines": {
44
46
  "node": ">=16.0.0"