architect-ai 1.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 ADDED
@@ -0,0 +1,182 @@
1
+ # 🛡️ ArchitectAI: The AI-Powered Code Guardian
2
+
3
+ > **Your 24/7 Virtual Technical Lead.**
4
+ > High-performance CLI tool to automate code reviews, enforce architectural patterns, and maintain clean code at scale using Generative AI.
5
+
6
+ [![NPM Version](https://img.shields.io/badge/npm-v1.1.0-blue?style=flat-square)](https://www.npmjs.com/)
7
+ [![Build Status](https://img.shields.io/badge/build-passing-green?style=flat-square)](https://github.com/minhnn/architect-ai)
8
+ [![Powered By](https://img.shields.io/badge/AI-Gemini%20Pro-purple?style=flat-square)](https://deepmind.google/technologies/gemini/)
9
+ [![License](https://img.shields.io/badge/license-MIT-gray?style=flat-square)]()
10
+
11
+ ---
12
+
13
+ ## 🚀 Why ArchitectAI?
14
+
15
+ Traditional tools like **ESLint** or **Prettier** are great for syntax and formatting, but they miss the bigger picture. They can't tell you if your logic is flawed or if you're breaking the project's architecture.
16
+
17
+ **ArchitectAI fills that gap.** v1.1.0 introduces a high-performance, concurrent engine that audits your code in parallel.
18
+
19
+ * ❌ **No Architectural Violations:** (e.g., calling Database directly from a Controller).
20
+ * ❌ **No Anti-Patterns:** (e.g., using `useEffect` for data fetching instead of `useQuery`).
21
+ * ✅ **Clean Code Enforcement:** Checks for readability, SOLID principles, and proper code splitting.
22
+ * ⚡ **High Performance:** Concurrent file auditing and ESM-native architecture.
23
+
24
+ ---
25
+
26
+ ## 📦 Installation
27
+
28
+ ```bash
29
+ # Run once without installing
30
+ npx @minhnn/architect-ai
31
+
32
+ # Or install globally
33
+ npm install -g @minhnn/architect-ai
34
+
35
+ # Or add as dev dependency (recommended)
36
+ npm install -D @minhnn/architect-ai
37
+ # pnpm add -D @minhnn/architect-ai
38
+ # yarn add -D @minhnn/architect-ai
39
+ ```
40
+
41
+ ## �️ CLI Usage
42
+
43
+ ```bash
44
+ # Default: Audit commit message + changed files
45
+ architect-ai
46
+
47
+ # Audit only changed files (skip commit check)
48
+ architect-ai --skip-commit
49
+
50
+ # Audit specific files
51
+ architect-ai src/main.ts src/utils.ts
52
+
53
+ # Set max concurrency (default: 5)
54
+ architect-ai --concurrency 10
55
+
56
+ # Diff against a specific branch
57
+ architect-ai --target-branch develop
58
+ ```
59
+
60
+ ### Options Reference
61
+
62
+ | Option | Shorthand | Description | Default |
63
+ |--------|-----------|-------------|---------|
64
+ | `--help` | `-h` | Show help message | - |
65
+ | `--version` | `-v` | Show version number | - |
66
+ | `--skip-commit`| - | Skip commit message validation | `false` |
67
+ | `--skip-files` | - | Skip file auditing | `false` |
68
+ | `--target-branch`| `-b` | Target branch for git diff | `origin/main` |
69
+ | `--concurrency` | `-c` | Max concurrent file audits | `5` |
70
+ | `--verbose` | - | Enable verbose logging | `false` |
71
+
72
+ ---
73
+
74
+ ## ⚙️ Configuration (`.architectrc.json`)
75
+
76
+ Create a `.architectrc.json` in your project root to customize rules and performance.
77
+
78
+ ```json
79
+ {
80
+ "techStack": "React 19, Next.js (App Router), TanStack Query v5",
81
+ "rules": [
82
+ "CRITICAL: Never use 'useEffect' for data fetching. Suggest 'useQuery'.",
83
+ "STYLE: All components must use Arrow Functions.",
84
+ "PERFORMANCE: Split components exceeding 200 lines.",
85
+ "ARCHITECTURE: Business logic must stay in Services, not Controllers."
86
+ ],
87
+ "bypassKeyword": "skip:",
88
+ "maxConcurrency": 5
89
+ }
90
+ ```
91
+
92
+ ### � Environment Variables
93
+
94
+ ```bash
95
+ # Required: Get your key at https://aistudio.google.com/
96
+ GEMINI_API_KEY=your_api_key_here
97
+
98
+ # Optional: Set default target branch
99
+ TARGET_BRANCH=origin/main
100
+ ```
101
+
102
+ ---
103
+
104
+ ## 📚 Programmatic API
105
+
106
+ ArchitectAI can be used as a library in your own Node.js scripts.
107
+
108
+ ```typescript
109
+ import { auditFilesWithConcurrency, loadProjectConfig } from '@minhnn/architect-ai';
110
+
111
+ const config = await loadProjectConfig();
112
+ const results = await auditFilesWithConcurrency(
113
+ [{ path: 'src/index.ts', content: '...' }],
114
+ config
115
+ );
116
+ ```
117
+
118
+ ---
119
+
120
+ ## 🤖 CI/CD Integration
121
+
122
+ ### GitHub Actions (`.github/workflows/audit.yml`)
123
+
124
+ ```yaml
125
+ name: ArchitectAI Code Guard
126
+ on:
127
+ pull_request:
128
+ types: [opened, synchronize]
129
+
130
+ jobs:
131
+ audit:
132
+ runs-on: ubuntu-latest
133
+ steps:
134
+ - uses: actions/checkout@v4
135
+ with:
136
+ fetch-depth: 0
137
+ - uses: actions/setup-node@v4
138
+ with:
139
+ node-version: '20'
140
+ - run: npm ci
141
+ - name: Run ArchitectAI
142
+ env:
143
+ GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
144
+ TARGET_BRANCH: origin/${{ github.base_ref }}
145
+ run: npx @minhnn/architect-ai
146
+
147
+ ### GitLab CI (`.gitlab-ci.yml`)
148
+
149
+ ```yaml
150
+ audit:
151
+ image: node:20
152
+ stage: test
153
+ cache:
154
+ paths:
155
+ - .npm/
156
+ before_script:
157
+ - npm ci --cache .npm --prefer-offline
158
+ - git fetch origin main
159
+ script:
160
+ - export TARGET_BRANCH="origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-main}"
161
+ - npx @minhnn/architect-ai --target-branch $TARGET_BRANCH
162
+ variables:
163
+ GEMINI_API_KEY: $GEMINI_API_KEY
164
+ rules:
165
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
166
+ ```
167
+
168
+ ---
169
+
170
+ ## 💡 How it Works
171
+
172
+ 1. **Smart Diff**: Detects only relevant code changes against your target branch.
173
+ 2. **Concurrent Audit**: Files are processed in parallel batches for maximum speed.
174
+ 3. **AI Reasoning**: Your code + project rules are analyzed by Gemini 1.5 Pro.
175
+ 4. **Actionable Reports**: Styled console output with line-specific suggestions.
176
+ 5. **Exit Codes**: Returns `1` on CRITICAL issues to block bad PRs.
177
+
178
+ ---
179
+
180
+ ## 🛡️ License
181
+ Copyright © 2026 MinhNN. All rights reserved.
182
+ Distributed under the MIT License.