@polarityinc/paragon 0.0.12 → 0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polarityinc/paragon",
3
- "version": "0.0.12",
3
+ "version": "0.1.0",
4
4
  "description": "Paragon is the First AI QA Engineer and the Worlds best code reviewer.",
5
5
  "author": "Polarity Inc.",
6
6
  "private": false,
@@ -81,6 +81,16 @@ function downloadFile(url, dest) {
81
81
  });
82
82
  }
83
83
 
84
+ // Check if a command exists
85
+ function commandExists(cmd) {
86
+ try {
87
+ execSync(`which ${cmd}`, { stdio: 'ignore' });
88
+ return true;
89
+ } catch (e) {
90
+ return false;
91
+ }
92
+ }
93
+
84
94
  // Check for ripgrep
85
95
  function checkRipgrep() {
86
96
  try {
@@ -91,79 +101,220 @@ function checkRipgrep() {
91
101
  }
92
102
  }
93
103
 
94
- // Install ripgrep automatically
95
- function installRipgrep() {
96
- console.log('Installing ripgrep...');
104
+ // Check if Homebrew is available
105
+ function hasHomebrew() {
106
+ try {
107
+ execSync('brew --version', { stdio: 'ignore' });
108
+ return true;
109
+ } catch (e) {
110
+ return false;
111
+ }
112
+ }
97
113
 
114
+ // Check if pip/pipx is available
115
+ function hasPipx() {
98
116
  try {
117
+ execSync('pipx --version', { stdio: 'ignore' });
118
+ return true;
119
+ } catch (e) {
120
+ return false;
121
+ }
122
+ }
123
+
124
+ function hasPip() {
125
+ try {
126
+ execSync('pip3 --version', { stdio: 'ignore' });
127
+ return true;
128
+ } catch (e) {
129
+ return false;
130
+ }
131
+ }
132
+
133
+ // Install a tool using available package manager
134
+ function installTool(toolName, brewName, pipxName, aptName) {
135
+ if (commandExists(toolName)) {
136
+ console.log(` ✓ ${toolName} already installed`);
137
+ return true;
138
+ }
139
+
140
+ console.log(` Installing ${toolName}...`);
141
+
142
+ // Try Homebrew first (macOS and Linux)
143
+ if (hasHomebrew()) {
144
+ try {
145
+ execSync(`brew install ${brewName || toolName}`, { stdio: 'inherit' });
146
+ console.log(` ✓ ${toolName} installed via Homebrew`);
147
+ return true;
148
+ } catch (e) {
149
+ console.log(` ⚠ Failed to install ${toolName} via Homebrew`);
150
+ }
151
+ }
152
+
153
+ // Try pipx for Python-based tools
154
+ if (pipxName && hasPipx()) {
155
+ try {
156
+ execSync(`pipx install ${pipxName}`, { stdio: 'inherit' });
157
+ console.log(` ✓ ${toolName} installed via pipx`);
158
+ return true;
159
+ } catch (e) {
160
+ console.log(` ⚠ Failed to install ${toolName} via pipx`);
161
+ }
162
+ }
163
+
164
+ // Try pip for Python-based tools
165
+ if (pipxName && hasPip()) {
166
+ try {
167
+ execSync(`pip3 install ${pipxName}`, { stdio: 'inherit' });
168
+ console.log(` ✓ ${toolName} installed via pip`);
169
+ return true;
170
+ } catch (e) {
171
+ console.log(` ⚠ Failed to install ${toolName} via pip`);
172
+ }
173
+ }
174
+
175
+ // Linux: try apt
176
+ if (platform === 'linux' && aptName) {
177
+ try {
178
+ // Check if apt is available
179
+ execSync('apt --version', { stdio: 'ignore' });
180
+ console.log(` Attempting apt install (may require sudo)...`);
181
+ execSync(`sudo apt update && sudo apt install -y ${aptName}`, { stdio: 'inherit' });
182
+ console.log(` ✓ ${toolName} installed via apt`);
183
+ return true;
184
+ } catch (e) {
185
+ // apt not available or failed
186
+ }
187
+ }
188
+
189
+ return false;
190
+ }
191
+
192
+ // Show manual installation instructions for security tools
193
+ function showSecurityToolInstructions(toolName) {
194
+ console.log(`\n⚠️ ${toolName} could not be auto-installed`);
195
+ console.log(`\nPlease install it manually:\n`);
196
+
197
+ if (toolName === 'trivy') {
99
198
  if (platform === 'darwin') {
100
- // macOS - try brew
101
- try {
102
- execSync('brew --version', { stdio: 'ignore' });
103
- console.log('Installing ripgrep via Homebrew...');
104
- execSync('brew install ripgrep', { stdio: 'inherit' });
105
- return true;
106
- } catch (e) {
107
- console.error('✗ Homebrew not found. Please install Homebrew first: https://brew.sh');
108
- return false;
109
- }
199
+ console.log(' macOS (Homebrew):');
200
+ console.log(' brew install trivy\n');
110
201
  } else if (platform === 'linux') {
111
- // Linux - try various package managers
112
- // Try apt (Debian/Ubuntu)
113
- try {
114
- execSync('apt --version', { stdio: 'ignore' });
115
- console.log('Installing ripgrep via apt...');
116
- execSync('sudo apt update && sudo apt install -y ripgrep', { stdio: 'inherit' });
117
- return true;
118
- } catch (e) {
119
- // Try dnf (Fedora)
120
- try {
121
- execSync('dnf --version', { stdio: 'ignore' });
122
- console.log('Installing ripgrep via dnf...');
123
- execSync('sudo dnf install -y ripgrep', { stdio: 'inherit' });
124
- return true;
125
- } catch (e2) {
126
- // Try yum (RHEL/CentOS)
127
- try {
128
- execSync('yum --version', { stdio: 'ignore' });
129
- console.log('Installing ripgrep via yum...');
130
- execSync('sudo yum install -y ripgrep', { stdio: 'inherit' });
131
- return true;
132
- } catch (e3) {
133
- console.error('✗ No supported package manager found (apt/dnf/yum)');
134
- console.error('Please install ripgrep manually: https://github.com/BurntSushi/ripgrep');
135
- return false;
136
- }
137
- }
138
- }
139
- } else if (platform === 'windows') {
140
- // Windows - try choco first, then scoop
141
- try {
142
- execSync('choco --version', { stdio: 'ignore' });
143
- console.log('Installing ripgrep via Chocolatey...');
144
- execSync('choco install ripgrep -y', { stdio: 'inherit' });
145
- return true;
146
- } catch (e) {
147
- try {
148
- execSync('scoop --version', { stdio: 'ignore' });
149
- console.log('Installing ripgrep via Scoop...');
150
- execSync('scoop install ripgrep', { stdio: 'inherit' });
151
- return true;
152
- } catch (e2) {
153
- console.error('✗ No supported package manager found (choco/scoop)');
154
- console.error('Please install Chocolatey or Scoop first');
155
- return false;
156
- }
157
- }
202
+ console.log(' Debian/Ubuntu:');
203
+ console.log(' sudo apt-get install wget apt-transport-https gnupg lsb-release');
204
+ console.log(' wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -');
205
+ console.log(' echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list');
206
+ console.log(' sudo apt-get update && sudo apt-get install trivy\n');
207
+ }
208
+ console.log(' Or visit: https://aquasecurity.github.io/trivy/latest/getting-started/installation/\n');
209
+ } else if (toolName === 'semgrep') {
210
+ console.log(' Using pip/pipx:');
211
+ console.log(' pipx install semgrep');
212
+ console.log(' # or: pip3 install semgrep\n');
213
+ if (platform === 'darwin') {
214
+ console.log(' macOS (Homebrew):');
215
+ console.log(' brew install semgrep\n');
216
+ }
217
+ console.log(' Or visit: https://semgrep.dev/docs/getting-started/\n');
218
+ } else if (toolName === 'gitleaks') {
219
+ if (platform === 'darwin') {
220
+ console.log(' macOS (Homebrew):');
221
+ console.log(' brew install gitleaks\n');
222
+ } else if (platform === 'linux') {
223
+ console.log(' Download from GitHub releases:');
224
+ console.log(' https://github.com/gitleaks/gitleaks/releases\n');
225
+ }
226
+ console.log(' Or visit: https://github.com/gitleaks/gitleaks#installing\n');
227
+ }
228
+ }
229
+
230
+ // Install security scanning tools
231
+ function installSecurityTools() {
232
+ console.log('\n🔒 Installing security scanning tools...\n');
233
+
234
+ const tools = [
235
+ { name: 'trivy', brew: 'trivy', pipx: null, apt: null },
236
+ { name: 'semgrep', brew: 'semgrep', pipx: 'semgrep', apt: null },
237
+ { name: 'gitleaks', brew: 'gitleaks', pipx: null, apt: null },
238
+ ];
239
+
240
+ const failed = [];
241
+
242
+ for (const tool of tools) {
243
+ const success = installTool(tool.name, tool.brew, tool.pipx, tool.apt);
244
+ if (!success) {
245
+ failed.push(tool.name);
158
246
  }
159
- } catch (err) {
160
- console.error('✗ Failed to install ripgrep:', err.message);
247
+ }
248
+
249
+ if (failed.length > 0) {
250
+ console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
251
+ for (const toolName of failed) {
252
+ showSecurityToolInstructions(toolName);
253
+ }
254
+ } else {
255
+ console.log('\n✓ All security tools installed successfully!\n');
256
+ }
257
+ }
258
+
259
+ // Show instructions for installing ripgrep
260
+ function showRipgrepInstructions() {
261
+ console.log('\n⚠️ ripgrep is required but not found on your system');
262
+ console.log('\nPlease install it using your package manager:\n');
263
+
264
+ if (platform === 'darwin') {
265
+ console.log(' macOS (Homebrew):');
266
+ console.log(' brew install ripgrep\n');
267
+ } else if (platform === 'linux') {
268
+ console.log(' Debian/Ubuntu:');
269
+ console.log(' sudo apt update && sudo apt install ripgrep\n');
270
+ console.log(' Fedora:');
271
+ console.log(' sudo dnf install ripgrep\n');
272
+ console.log(' RHEL/CentOS:');
273
+ console.log(' sudo yum install ripgrep\n');
274
+ } else if (platform === 'windows') {
275
+ console.log(' Chocolatey:');
276
+ console.log(' choco install ripgrep\n');
277
+ console.log(' Scoop:');
278
+ console.log(' scoop install ripgrep\n');
279
+ }
280
+
281
+ console.log(' Or download from: https://github.com/BurntSushi/ripgrep#installation\n');
282
+ return false;
283
+ }
284
+
285
+ // Install osgrep for semantic code search
286
+ function installOsgrep() {
287
+ console.log('\n🔍 Installing osgrep for semantic code search...\n');
288
+
289
+ // Check if osgrep is already installed
290
+ if (commandExists('osgrep')) {
291
+ console.log(' ✓ osgrep already installed');
292
+ return true;
293
+ }
294
+
295
+ // Install via npm
296
+ try {
297
+ console.log(' Installing osgrep via npm...');
298
+ execSync('npm install -g osgrep', { stdio: 'inherit' });
299
+ console.log(' ✓ osgrep installed via npm');
300
+
301
+ // Run osgrep setup to download embedding models
302
+ console.log(' Setting up osgrep (downloading embedding models)...');
303
+ execSync('osgrep setup', { stdio: 'inherit' });
304
+ console.log(' ✓ osgrep setup complete');
305
+
306
+ return true;
307
+ } catch (e) {
308
+ console.log(' ⚠ Failed to install osgrep');
309
+ console.log('\n To enable semantic code search, install manually:');
310
+ console.log(' npm install -g osgrep');
311
+ console.log(' osgrep setup\n');
161
312
  return false;
162
313
  }
163
314
  }
164
315
 
165
- // Uninstall brew version if it exists
166
- function uninstallBrewPolarity() {
316
+ // Check for brew version conflict
317
+ function checkBrewPolarity() {
167
318
  if (platform !== 'darwin') {
168
319
  return; // Only relevant for macOS
169
320
  }
@@ -175,9 +326,9 @@ function uninstallBrewPolarity() {
175
326
  // Check if polarity is installed via brew
176
327
  try {
177
328
  execSync('brew list polarity', { stdio: 'ignore' });
178
- console.log('Found existing Homebrew installation of polarity, uninstalling...');
179
- execSync('brew uninstall polarity', { stdio: 'inherit' });
180
- console.log(' Homebrew polarity uninstalled successfully\n');
329
+ console.log('⚠️ Warning: Homebrew version of polarity is installed');
330
+ console.log('This may conflict with the npm version.');
331
+ console.log('Consider uninstalling it with: brew uninstall polarity\n');
181
332
  } catch (e) {
182
333
  // polarity not installed via brew, which is fine
183
334
  }
@@ -186,8 +337,8 @@ function uninstallBrewPolarity() {
186
337
  }
187
338
  }
188
339
 
189
- // Uninstall brew version before installing npm version
190
- uninstallBrewPolarity();
340
+ // Check for potential brew conflicts
341
+ checkBrewPolarity();
191
342
 
192
343
  downloadFile(GITHUB_RELEASE_URL, binPath)
193
344
  .then(() => {
@@ -207,23 +358,26 @@ downloadFile(GITHUB_RELEASE_URL, binPath)
207
358
  console.log('\n The Best Code Review Agent in the World\n');
208
359
  console.log('✓ Paragon installed successfully!\n');
209
360
 
210
- // Check and install ripgrep if needed
361
+ // Check for ripgrep
211
362
  if (!checkRipgrep()) {
212
- if (!installRipgrep()) {
213
- console.log('⚠️ Could not auto-install ripgrep');
214
- console.log('Please install it manually: https://github.com/BurntSushi/ripgrep#installation\n');
215
- } else {
216
- console.log('✓ ripgrep installed automatically!\n');
217
- }
363
+ showRipgrepInstructions();
218
364
  }
219
365
 
366
+ // Install security scanning tools (trivy, semgrep, gitleaks)
367
+ installSecurityTools();
368
+
369
+ // Install osgrep for semantic code search
370
+ installOsgrep();
371
+
220
372
  console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
221
373
  console.log('\n📝 Next Steps:\n');
222
374
  console.log(' 1. Authenticate with Polarity:');
223
375
  console.log(' $ paragon auth login\n');
224
376
  console.log(' 2. Get your API key from:');
225
377
  console.log(' https://home.polarity.cc/app/settings\n');
226
- console.log(' 3. Start using Paragon:');
378
+ console.log(' 3. Index your repository for semantic search:');
379
+ console.log(' $ paragon (then run /index from command palette)\n');
380
+ console.log(' 4. Start using Paragon:');
227
381
  console.log(' $ paragon\n');
228
382
  console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
229
383
  console.log('\n📚 Documentation: https://polarity.cc/docs');