aico-ai 1.1.2 → 1.1.4

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
@@ -9,6 +9,7 @@
9
9
  - **Multi-Provider Support**: Groq, OpenAI, DeepSeek, Gemini, or local Ollama
10
10
  - **Auto-Fix Suggestions**: Apply AI-recommended fixes with one click
11
11
  - **Parallel Processing**: Fast reviews even for large diffs
12
+ - **Code Explanation**: Get instant explanations for complex files
12
13
 
13
14
  ### Team Rules Engine
14
15
  - **Custom Standards**: Define your team's code quality rules
@@ -175,6 +176,12 @@ aico review
175
176
  # Generate AI commit message
176
177
  aico commit
177
178
 
179
+ # Generate Pull Request description
180
+ aico pr
181
+
182
+ # Explain the code and commit that was generated
183
+ aico explain
184
+
178
185
  # Run security scan
179
186
  aico security scan
180
187
 
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { getStagedDiff, applyFix, getDiffChunks } from './lib/git-utils.js';
3
- import { reviewCode, generateCommitMessage } from './lib/ai-service.js';
3
+ import { reviewCode, generateCommitMessage, generatePRDescription, explainCode } from './lib/ai-service.js';
4
4
  import { parseAIResponse, displayIssues } from './lib/reviewer.js';
5
5
  import {
6
6
  initializeTeamRules,
@@ -715,7 +715,9 @@ ${pc.bold('Usage:')}
715
715
  ${pc.bold('Commands:')}
716
716
  ${pc.cyan('review')} Analyze staged changes and suggest improvements (default)
717
717
  ${pc.cyan('commit')} Generate and apply an AI-suggested commit message
718
+ ${pc.cyan('pr')} Generate Pull Request description from diff
718
719
  ${pc.cyan('ci')} Run in CI/CD mode with machine-readable output
720
+ ${pc.cyan('explain <file>')} Explain a specific file
719
721
  ${pc.cyan('security <subcommand>')} Security vulnerability scanning
720
722
  ${pc.dim('scan')} Full security scan (dependencies + code + config)
721
723
  ${pc.dim('check')} Check specific areas (--dependencies or --code)
@@ -742,6 +744,8 @@ ${pc.bold('Options:')}
742
744
  ${pc.bold('Examples:')}
743
745
  aico review --silent
744
746
  aico commit
747
+ aico pr
748
+ aico explain src/utils.js
745
749
  aico ci --format json --output report.json
746
750
  aico security scan
747
751
  aico security check --dependencies
@@ -790,6 +794,73 @@ async function main() {
790
794
  return;
791
795
  }
792
796
 
797
+ if (command === 'pr') {
798
+ try {
799
+ const currentBranch = execSync('git branch --show-current').toString().trim();
800
+
801
+ // Try to detect base branch (main, master, or develop)
802
+ let baseBranch = 'main';
803
+ const branches = ['main', 'master', 'develop', 'dev'];
804
+ for (const branch of branches) {
805
+ try {
806
+ execSync(`git rev-parse --verify origin/${branch}`, { stdio: 'ignore' });
807
+ baseBranch = branch;
808
+ break;
809
+ } catch (e) {
810
+ continue;
811
+ }
812
+ }
813
+
814
+ console.log(pc.dim(`Comparing ${currentBranch} with origin/${baseBranch}...`));
815
+ const diff = execSync(`git diff origin/${baseBranch}...${currentBranch}`).toString();
816
+
817
+ if (!diff || diff.trim() === '') {
818
+ console.log(pc.yellow(`No differences found between ${currentBranch} and origin/${baseBranch}.`));
819
+ return;
820
+ }
821
+
822
+ startSpinner('Generating PR description...');
823
+ const description = await generatePRDescription(diff);
824
+ stopSpinner();
825
+
826
+ console.log(pc.bold('\nšŸ“ Suggested PR Description:\n'));
827
+ console.log(description);
828
+ } catch (error) {
829
+ stopSpinner();
830
+ console.error(pc.red('Error generating PR description:'), error.message);
831
+ process.exit(1);
832
+ }
833
+ return;
834
+ }
835
+
836
+ if (command === 'explain') {
837
+ const filePath = args[1];
838
+ if (!filePath) {
839
+ console.error(pc.red('Please provide a file path: aico explain <file>'));
840
+ return;
841
+ }
842
+
843
+ if (!fs.existsSync(filePath)) {
844
+ console.error(pc.red(`File not found: ${filePath}`));
845
+ return;
846
+ }
847
+
848
+ try {
849
+ const content = fs.readFileSync(filePath, 'utf-8');
850
+ startSpinner(`Analyzing ${filePath}...`);
851
+ const explanation = await explainCode(content, filePath);
852
+ stopSpinner();
853
+
854
+ console.log(pc.bold(`\nšŸ“˜ Explanation for ${filePath}:\n`));
855
+ console.log(explanation);
856
+ } catch (error) {
857
+ stopSpinner();
858
+ console.error(pc.red('Error explaining file:'), error.message);
859
+ process.exit(1);
860
+ }
861
+ return;
862
+ }
863
+
793
864
  if (command !== 'review' && command !== 'commit') {
794
865
  console.error(pc.red(`Unknown command: ${command}`));
795
866
  console.log(`Run ${pc.cyan('aico help')} to see available commands.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aico-ai",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,271 +0,0 @@
1
- # GitHub Packages Setup Guide
2
-
3
- This guide explains how to publish and install the `aico-ai` package from GitHub Packages.
4
-
5
- ## šŸ“¦ Dual Publishing Strategy
6
-
7
- The `aico-ai` package is published to **two registries**:
8
-
9
- 1. **npm Registry** (default): `aico-ai`
10
- 2. **GitHub Packages**: `@lukasddesouza/aico-ai`
11
-
12
- Both packages are identical in functionality. Choose the registry that best fits your workflow.
13
-
14
- ---
15
-
16
- ## šŸš€ For Package Maintainers (Publishing)
17
-
18
- ### Prerequisites
19
-
20
- 1. **GitHub Personal Access Token** with the following scopes:
21
- - `write:packages` - To publish packages
22
- - `read:packages` - To download packages
23
- - `repo` - To access repository (if private)
24
-
25
- 2. **npm Token** (for npm publishing)
26
- - Get from https://www.npmjs.com/settings/YOUR_USERNAME/tokens
27
-
28
- ### Creating a GitHub Personal Access Token
29
-
30
- 1. Go to [GitHub Settings → Developer settings → Personal access tokens](https://github.com/settings/tokens)
31
- 2. Click **"Generate new token (classic)"**
32
- 3. Give it a descriptive name (e.g., "aico-ai GitHub Packages")
33
- 4. Select the following scopes:
34
- - āœ… `write:packages`
35
- - āœ… `read:packages`
36
- - āœ… `repo` (if repository is private)
37
- 5. Click **"Generate token"**
38
- 6. **Copy the token immediately** (you won't see it again!)
39
-
40
- ### Setting Up Repository Secrets
41
-
42
- For automated publishing via GitHub Actions, add these secrets to your repository:
43
-
44
- 1. Go to your repository on GitHub
45
- 2. Navigate to **Settings → Secrets and variables → Actions**
46
- 3. Click **"New repository secret"**
47
- 4. Add the following secrets:
48
-
49
- - **Name:** `NPM_TOKEN`
50
- - **Value:** Your npm authentication token
51
-
52
- - **Note:** `GITHUB_TOKEN` is automatically provided by GitHub Actions
53
-
54
- ### Publishing Workflow
55
-
56
- The package is automatically published when you create a new release:
57
-
58
- #### Option 1: Automatic Publishing (Recommended)
59
-
60
- 1. **Update version in package.json:**
61
- ```bash
62
- npm version patch # or minor, or major
63
- ```
64
-
65
- 2. **Push the version commit and tag:**
66
- ```bash
67
- git push && git push --tags
68
- ```
69
-
70
- 3. **Create a GitHub Release:**
71
- - Go to your repository on GitHub
72
- - Click **"Releases"** → **"Create a new release"**
73
- - Select the tag you just pushed
74
- - Add release notes
75
- - Click **"Publish release"**
76
-
77
- 4. **GitHub Actions will automatically:**
78
- - Publish to npm as `aico-ai`
79
- - Publish to GitHub Packages as `@lukasddesouza/aico-ai`
80
-
81
- #### Option 2: Manual Publishing
82
-
83
- **To npm:**
84
- ```bash
85
- npm publish
86
- ```
87
-
88
- **To GitHub Packages:**
89
- ```bash
90
- # 1. Authenticate with GitHub Packages
91
- npm login --scope=@lukasddesouza --registry=https://npm.pkg.github.com
92
-
93
- # 2. Temporarily update package.json name
94
- # Change "name": "aico-ai" to "name": "@lukasddesouza/aico-ai"
95
-
96
- # 3. Update publishConfig in package.json
97
- # "publishConfig": {
98
- # "registry": "https://npm.pkg.github.com"
99
- # }
100
-
101
- # 4. Publish
102
- npm publish
103
-
104
- # 5. Restore package.json to original state
105
- git checkout package.json
106
- ```
107
-
108
- ---
109
-
110
- ## šŸ“„ For Package Users (Installing)
111
-
112
- ### Installing from npm (Default)
113
-
114
- This is the standard installation method:
115
-
116
- ```bash
117
- npm install -g aico-ai
118
- ```
119
-
120
- ### Installing from GitHub Packages
121
-
122
- #### Step 1: Authenticate with GitHub Packages
123
-
124
- Create a `.npmrc` file in your project root (or use the global `~/.npmrc`):
125
-
126
- ```bash
127
- # Copy the template
128
- cp .npmrc.template .npmrc
129
- ```
130
-
131
- Edit `.npmrc` and replace `TOKEN` with your GitHub Personal Access Token:
132
-
133
- ```
134
- @lukasddesouza:registry=https://npm.pkg.github.com
135
- //npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
136
- ```
137
-
138
- **Important:** Never commit `.npmrc` with your token to git! It's already in `.gitignore`.
139
-
140
- #### Step 2: Install the Package
141
-
142
- **Global installation:**
143
- ```bash
144
- npm install -g @lukasddesouza/aico-ai
145
- ```
146
-
147
- **Project installation:**
148
- ```bash
149
- npm install --save-dev @lukasddesouza/aico-ai
150
- ```
151
-
152
- #### Alternative: Using npm login
153
-
154
- Instead of creating `.npmrc`, you can authenticate via CLI:
155
-
156
- ```bash
157
- npm login --scope=@lukasddesouza --registry=https://npm.pkg.github.com
158
- ```
159
-
160
- Then enter:
161
- - **Username:** Your GitHub username
162
- - **Password:** Your GitHub Personal Access Token
163
- - **Email:** Your GitHub email
164
-
165
- ---
166
-
167
- ## šŸ” Security Best Practices
168
-
169
- ### For Maintainers
170
-
171
- 1. **Never commit tokens to git**
172
- - `.npmrc` is in `.gitignore`
173
- - Use GitHub Secrets for CI/CD
174
-
175
- 2. **Use scoped tokens**
176
- - Create separate tokens for different purposes
177
- - Regularly rotate tokens
178
-
179
- 3. **Enable 2FA**
180
- - Enable two-factor authentication on both npm and GitHub
181
-
182
- ### For Users
183
-
184
- 1. **Protect your tokens**
185
- - Never share your Personal Access Token
186
- - Don't commit `.npmrc` with tokens
187
-
188
- 2. **Use read-only tokens when possible**
189
- - For installation, you only need `read:packages` scope
190
-
191
- 3. **Use environment variables in CI/CD**
192
- ```bash
193
- echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" > .npmrc
194
- ```
195
-
196
- ---
197
-
198
- ## šŸ†š npm vs GitHub Packages: Which Should I Use?
199
-
200
- ### Use **npm** if:
201
- - āœ… You want the simplest installation experience
202
- - āœ… You're installing globally (`npm install -g`)
203
- - āœ… You don't need GitHub-specific features
204
- - āœ… You want maximum compatibility
205
-
206
- ### Use **GitHub Packages** if:
207
- - āœ… You prefer GitHub-native workflows
208
- - āœ… You want tighter integration with GitHub repositories
209
- - āœ… You're already using GitHub for dependency management
210
- - āœ… You need private packages (with GitHub Teams/Enterprise)
211
-
212
- ---
213
-
214
- ## šŸ› Troubleshooting
215
-
216
- ### "Unable to authenticate" error
217
-
218
- **Problem:** npm can't authenticate with GitHub Packages
219
-
220
- **Solution:**
221
- 1. Verify your token has `read:packages` scope
222
- 2. Check that `.npmrc` is properly configured
223
- 3. Ensure the token hasn't expired
224
-
225
- ```bash
226
- # Test authentication
227
- npm whoami --registry=https://npm.pkg.github.com
228
- ```
229
-
230
- ### "Package not found" error
231
-
232
- **Problem:** npm can't find `@lukasddesouza/aico-ai`
233
-
234
- **Solution:**
235
- 1. Ensure you're using the scoped name: `@lukasddesouza/aico-ai`
236
- 2. Check that `.npmrc` has the correct registry mapping
237
- 3. Verify the package has been published
238
-
239
- ### "Permission denied" error
240
-
241
- **Problem:** Can't publish to GitHub Packages
242
-
243
- **Solution:**
244
- 1. Verify your token has `write:packages` scope
245
- 2. Ensure you're the repository owner or have write access
246
- 3. Check that the package name matches the repository owner
247
-
248
- ---
249
-
250
- ## šŸ“š Additional Resources
251
-
252
- - [GitHub Packages Documentation](https://docs.github.com/en/packages)
253
- - [npm Documentation](https://docs.npmjs.com/)
254
- - [Working with the npm registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry)
255
- - [Managing Personal Access Tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
256
-
257
- ---
258
-
259
- ## šŸ’¬ Support
260
-
261
- If you encounter any issues:
262
-
263
- - šŸ“§ Email: projetos@codetechsoftware.com.br
264
- - šŸ› Issues: [GitHub Issues](https://github.com/LukasdeSouza/aico-ai/issues)
265
- - šŸ’¬ Discussions: [GitHub Discussions](https://github.com/LukasdeSouza/aico-ai/discussions)
266
-
267
- ---
268
-
269
- ## šŸ“ License
270
-
271
- ISC License - see [LICENSE](LICENSE) file for details
package/TODO.md DELETED
@@ -1,51 +0,0 @@
1
- # GitHub Packages Setup - TODO List
2
-
3
- ## Progress Tracker
4
-
5
- - [x] 1. Update package.json with publishConfig
6
- - [x] 2. Create .npmrc.template for user reference
7
- - [x] 3. Create GitHub Actions workflow for automated publishing
8
- - [x] 4. Create GITHUB_PACKAGES.md documentation
9
- - [x] 5. Update README.md with GitHub Packages installation instructions
10
- - [ ] 6. Test and verify setup
11
-
12
- ## Completed Steps
13
-
14
- āœ… **package.json** - Added publishConfig for npm registry
15
- āœ… **.npmrc.template** - Created template with GitHub Packages authentication instructions
16
- āœ… **.github/workflows/publish.yml** - Created automated dual-publishing workflow
17
- āœ… **GITHUB_PACKAGES.md** - Created comprehensive documentation
18
- āœ… **README.md** - Added GitHub Packages installation section with badges
19
-
20
- ## Next Steps (Manual)
21
-
22
- ### For You to Complete:
23
-
24
- 1. **Create GitHub Personal Access Token**
25
- - Go to: https://github.com/settings/tokens
26
- - Click "Generate new token (classic)"
27
- - Select scopes: `write:packages`, `read:packages`
28
- - Copy the token
29
-
30
- 2. **Add NPM_TOKEN Secret to Repository**
31
- - Go to: https://github.com/LukasdeSouza/aico-ai/settings/secrets/actions
32
- - Click "New repository secret"
33
- - Name: `NPM_TOKEN`
34
- - Value: Your npm authentication token
35
- - Click "Add secret"
36
-
37
- 3. **Test the Publishing Workflow**
38
- - Option A: Create a new release on GitHub
39
- - Option B: Manually trigger the workflow from Actions tab
40
- - Option C: Push a new version tag
41
-
42
- 4. **Verify Packages**
43
- - Check npm: https://www.npmjs.com/package/aico-ai
44
- - Check GitHub Packages: https://github.com/LukasdeSouza/aico-ai/packages
45
-
46
- ## Notes
47
- - Dual publishing to npm and GitHub Packages
48
- - npm: aico-ai (existing)
49
- - GitHub Packages: @lukasddesouza/aico-ai (new)
50
- - Workflow uses GITHUB_TOKEN (automatic) for GitHub Packages
51
- - Workflow uses NPM_TOKEN (secret) for npm publishing